Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Shortcut menu class for VFP 9
Message
From
20/10/2007 01:10:27
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Miscellaneous
Thread ID:
01261771
Message ID:
01262316
Views:
24
Hi Ben

Thank you for your comments, they are very valuable.
>
>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).
>
That check is there because if there is selected text, there is no caret, so there is no caret position, and since a key was used to call the context menu, the mouse position should not be used, since the mouse cursor could be anywhere, that is why the positon defaults to about 1/3 right and down of the control.

I have already moved this code to a ShowMenuAtCaret(This) method in the shortcut class, then the code would be:
*!* KeyPress Event
Lparameters nKeyCode, nShiftAltCtrl

*!* "Context Menu" key = SHIFT+F10
If m.nKeyCode = 93 And m.nShiftAltCtrl = 1 Then
This.oContextMenu.ShowMenuAtCaret(This)
endif
>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.

m.lnX and m.lnY are optional, defaults to mouse pointer. In the same editbox RightClick you would have:
This.oContextMenu.ShowMenu()
Thank you for your comments.

Carlos
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform