Author
|
Topic: Notifications
|
Jeffrey Smith Member
|
posted 03-06-2008 02:25 PM
I'm trying to catch the cursor and mouse messages to create a selection area on a EGRID control. In the documentation for EGRID it says: "If The notification message returns TRUE, then no further actions will be taken". I thought all I had to do was set Cancel& = TRUE in the control events sub. I'm trying to prevent egrid from automatically resetting the cursor location when I hold down the shift key and cursor.code:
SUB DE_EGRID1_Events( MyID&, CMsg&, CVal&, Cancel&) STATIC SHIFTKey&, CTRLKey&, RangeX1 AS LONG, RangeY1 AS LONG, RangeX2 AS LONG, RangeY2 AS LONG, RangeState AS INTEGER LOCAL MYRECT AS RECT, MaxCols AS INTEGER, MaxRows AS INTEGER, TLong& SELECT CASE CMsg& CASE %EGN_SELECTIONCHANGED MSGBOX "changed" 'This doesn't work CASE %EZ_Click CASE %EZ_KeyDown SHIFTKey&=EZ_GetKeyState(%EZK_SHIFT,0) AND 1 IF ShiftKey& = 1 THEN RangeX1& = EZ_SENDMESSAGER("DE",MyID&, %EG_GETFOCUSEDCELLX, 0, 0) RangeY1& = EZ_SENDMESSAGER("DE",MyID&, %EG_GETFOCUSEDCELLY, 0, 0) END IF CTRLKey&=EZ_GetKeyState(%EZK_CTRL,0) AND 1 CASE %EZ_KeyUp IF CVal& =>37 AND CVal& =< 40 AND ShiftKey& = 1 THEN CANCEL& = %TRUE RangeX2& = EZ_SENDMESSAGER("DE",MyID&, %EG_GETFOCUSEDCELLX, 0, 0) RangeY2& = EZ_SENDMESSAGER("DE",MyID&, %EG_GETFOCUSEDCELLY, 0, 0) 'msgdp "1:" & STR$(RangeX1&) & " " & STR$(RangeY1&) 'msgdp "2:" & STR$(RangeX2&) & " " & STR$(RangeY2&) IF RangeX2& - RangeX1 < 0 THEN TLong& = RangeX1 RangeX1 = RangeX2 RangeX2 = TLong& END IF IF RangeY2 - RangeY1 < 0 THEN TLong& = RangeY1 RangeY1 = RangeY2 RangeY2 = TLong& END IF SETRECT MYRECT, RangeX1&, RangeY1&, RangeX2&, RangeY2& EZ_SENDMESSAGE "DE", MyID&, %EG_SETINTERNALSELECTION, VARPTR(MYRECT), 0 Result& = EZ_SENDMESSAGER("DE", MyID&, %EG_INTERNTOVISIBLE, 0, 0) EZ_SENDMESSAGE "DE", MyID&, %EG_REFRESHALL, 0, 0 END IF 'IF CVal& =>37 AND CVal& =< 40 AND CTRLKey& = 1 THEN CASE %EZ_KeyPress CASE %EZ_RButtonUp CASE %EZ_LButtonDown CASE %EZ_LButtonUp CASE %EZ_Loaded CASE %EZ_Loading CASE ELSE END SELECT END SUB
|
Chris Boss Administrator
|
posted 03-06-2008 11:53 PM
If you set Cancel& to true, it simply prevents the message from being passed to Windows default processing.To return a value, you have to pass the return value in CVal&. ie. code:
Cancel&=1 ' tell EZGUI not to let Windows process message CVal&=1 ' this is the return value for WM_NOTIFY message
Make sure you don't attempt to use CVal& anymore, after you change its value for the return value.
[This message has been edited by Chris Boss (edited 03-06-2008).] |
Chris Boss Administrator
|
posted 03-06-2008 11:58 PM
One rule with %EZ_Notify:Never change the value of CVal& (the return value) unless you also set Cancel& to non-zero (1). Also never use CVal& (as a pointer) after you change its value in %EZ_Notify. | |