Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Retrieve mouse position

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Retrieve mouse position
#12926
Posted by: PeterJ 2009-05-22 21:07:54 Last edited by: PeterJ 2009-05-22 21:10:37 (Total edited 3 times)
I have a View definition like this:

/*
GUIBEGIN
WINDOW , 45, 163, 358, 239, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , Table View
	FONT 8, 400, MS Shell Dlg
	STATUS BOTTOM|GRIP, MyStatus
	VIEW 4, 19, 347, 184, REPORT|SINGLE|SHARE|EDIT|BORDER, , MyView
	PUSH 6, 209, 70, 14, TABSTOP, , ShowSel, , Record
	ENTRY 5, 4, 300, 12, H_AUTO|BORDER|TABSTOP, CLIENTEDGE, MyWord
	PUSH 311, 3, 40, 14, DEFAULT|TABSTOP, , Find, , Find
DEND

GUIEND
*/

in which I place a table:

ERROR = guiaddctl("VIEW 4, 19, 347, 184, REPORT|SINGLE|SHARE|EDIT|BORDER, , MyView")
DO i = 1 TO 2
	mycolumn.!width = 50  /* 1/2 of the VIEW control's width */
	SELECT i
		WHEN 1 THEN mycolumn.!text = "Column 1"
		WHEN 2 THEN mycolumn.!text = "Column 2"
	END
	mycolumn.!state = "LEFT"
	mycolumn.!subitem = i
	guiaddctltext("MyView", "MyColumn", 1)
END

and eventually fill it up with several entries in both columns. I would like to select single entries, either in column 1 or 2. The event handling allows me only to retrieve the line which has been selected, not the items (either col 1 or 2). I wonder if there is a way to read the mouse pointer where the selection took place. I could then map it either to column 1 or 2 myself. I played already with the mouse move event, but it does not react in a way which is useful, is there any other way to pick it up?

Peter
Message2.
#12946
Posted by: Jeff Glatt 2009-05-25 08:47:56
Just for the "Reginald Answer Guy", there's a new REXX GUI update that will do what you need. Download that new version of the add-on dll.

Also download the new version of the example script "view.rex". It shows how to handle a click on an item. When you click on an item, it pops up a message box telling which item number, and column number (within that item) you've clicked on. Try clicking the left or the right button (and notice you can differentiate between left and right with two separate CLICK and RCLICK handlers).

In a nutshell: After you GuiCreateWindow() with your view control, you then send your view control a "SETEXTENDEDLISTVIEWSTYLE" message (by calling GuiSendMsg). The third arg is a list of all the "features" you want to change for your view control. For example, if you want to change the "CLICK" feature (ie, the ability to receive a CLICK event when you click on an item), then you'll pass "CLICK". If you want to change both the "CLICK" and "FULLROW" features, then you'll pass "CLICK | FULLROW". (ie, Each feature name is separated by a | character). Then for the fourth arg to GuiSendMsg(), you pass the actual features you want to enable. (If you pass a feature name in the third arg, but not in the fourth arg, then the feature is turned off).

For example, assume the variable "MyView" is associated with your view control:
/* Turn on the CLICK and FULLROW features */
guisendmsg("MyView", "SETEXTENDEDLISTVIEWSTYLE", "CLICK|FULLROW", "CLICK|FULLROW")

/* Turn off the FULLROW feature */
guisendmsg("MyView", "SETEXTENDEDLISTVIEWSTYLE", "FULLROW")

/* Turn on the CLICK feature, and turn off FULLROW */
guisendmsg("MyView", "SETEXTENDEDLISTVIEWSTYLE", "CLICK|FULLROW", "CLICK")
Of course, you'll want to put an event handler for that "CLICK" event on your view control:
wm_click_myview:
   /* Called when user clicks on an item. The variable for our control is
    * set to which column was clicked upon, and the variable.1 is set to
    * the item number.
    */
   guisay("Clicked on column" myview "of item" myview.1)
   RETURN
Here are some features that may be useful to you:

"CLICK" tells the view control to cause a "CLICK" event when the user clicks the left mouse button upon an item, or a "RCLICK" event when the user clicks the right mouse button. The variable name associated with the control is set to the column number clicked upon. The variable name with a .1 tail is set to the item number clicked upon.

"DBLCLK" is like "CLICK" except the user must double-click on an item, and a "DBLCLK" or "RDBLCLK" event happens (depending upon which mouse button is double-clicked). Variables are set per "CLICK".

"FULLROW" makes the selected item highlighted across the full row (ie, all columns instead of only the first column).

"CHECKBOX" adds checkboxes to the items. "AUTOCHECK" sets the checkbox when the user single-clicks on an item.

"FLAT" shows the scroll bar as flat.

"AUTOCOLUMNS" automatically sizes a column to fit its text. (Vista only).

"BORDER" changes border color whan an item is selected, instead of highlighting the item.

"MINSNAP" snaps a column to a minimum size when user resizes it. (Vista only).

"GRID" displays grid lines around items/columns.

"TRACK" enables hot-track selection. Hot track selection means that an item is automatically selected when the cursor remains over the item for a certain period of time.
Message3.
#12950
Posted by: PeterJ 2009-05-26 04:07:35
Thanks a lot Jeff, I appreciate your effort! It works perfectly fine!
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Wed 2024-12-11  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0