Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Shortcut menu class for VFP 9
Message
 
To
19/10/2007 14:42:33
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Miscellaneous
Thread ID:
01261771
Message ID:
01262313
Views:
21
Hi Carlos,

Thank you for your information.

1) IMO the "If This.SelLength" checking is not needed and only the code for "This.SelLength=0" should be kept. It is because there may only be a small portion of the text selected, which is far above the bottom of a large editbox (or far from the right edge of a long textbox).

2) I suggest simplifying the mechanism for showing a context menu as This._ContextMenu() (making m.lnX and m.lnY optional). Your class will then detect if the Shift key is currently down. If no, then get the coordinates from the mouse pointer. Otherwise get the them from GetCaretPos(). IMO this will not only simplify the work of VFP programmers (and make their base class cleaner), but also benefit those who do not know the GetCaretPos() API.


Ben


>Hello Ben:
>
>Thank you for your feedback. Yes, this is already implemented in the class, well not exactly, but the calling code can be easily added to an editbox.
>
>Since the ctl32_shorcut menu can be called with x,y parameters, this will pop the menu at the cursor position:
>
>
>*!* KeyPress Event
>Lparameters nKeyCode, nShiftAltCtrl
>
>*!* "Context Menu" key = SHIFT+F10
>If m.nKeyCode = 93 And m.nShiftAltCtrl = 1 Then
>	Local;
>		m.lnX As Integer, ;
>		m.lnY As Integer, ;
>		m.lcPoint As String, ;
>		m.lnSelStart As Integer, ;
>		m.lnSelLength As Integer
>
>	*!* If no text is selected, get position of caret:
>
>	If This.SelLength = 0 Then
>
>		Declare Integer GetCaretPos In win32api ;
>			String @lpPoint
>
>		m.lcPoint = Space(8)
>		*!* Get position of caret
>		GetCaretPos(@m.lcPoint)
>		m.lnX = CToBin(Substr(m.lcPoint, 1, 4), [4RS]) + 5
>		m.lnY = CToBin(Substr(m.lcPoint, 5, 4), [4RS]) + 7
>	Else
>		*!* Text selected, get a point near right bottom corner of control:
>		m.lnX = Int(Objtoclient(This, 2) + This.Width /3*2)
>		m.lnY = Int(Objtoclient(This, 1) + This.Height /3*2)
>	Endif
>
>	This._ContextMenu(m.lnX, m.lnY)
>	Nodefault
>Endif
>
>
>
>Carlos Alloatti
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform