Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GetCaretPos() ignores cursor keys and mouse click
Message
De
07/04/2005 16:41:01
 
 
À
07/04/2005 12:26:36
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
01002065
Message ID:
01002418
Vues:
15
Cetin,

Thank you for your help on this thread. Your solution works great!

>You can get whatever effect you desire. Actually I just tested it and if you used in order I gave it popups in caret position if invoked by keyboard, else at mouse position.

Using your code, my popup always appears at the proper place. What I found confusing was when I right clicked, the popup would show up where I expected (at the point where I clicked), but if my popup was streaming text into the control itself based on the selected menu bar, the text was being inserted at the position of the caret - not at the point in the text where I right clicked.

In other words, I was under the impression that a right click would move the caret (cursor) to the point of my right click in exactly the same way as a left mouse click adjusts the position of the cursor. In fact, this is the way Word 2003 handles right clicks.

However, in my tests, VFP does not move the cursor (caret) in response to a right click in a textbox or editbox.

So, my solution was to add the following code to your RightClick() event code. What my code does is convert the right mouse click into a regular mouse click so as to have the control's cursor (caret) moved to the location where the user clicked. In my test environment I needed 3 doevents between the mouse click and the display of my shortcut menu, otherwise my shortcut menu would not appear, would appear and autoselect the first prompt or would appear and temporarily freeze.

Perhaps sleep() or a short inkey() pause might be a more robust solution to introducing a delay between the fake mouse click and the display of the shortcut popup?

[code]
lnRow = mrow()
lnCol = mcol()

mouse click at lnRow, lnCol window (wontop())

* minimum 3 doevents required or popup will be whacky
doevents
doevents
doevents

* build and display shortcut menu
do shortcutmenu.mpr with lnRow, lnCol, ThisForm

[/code]

Thanks again for your patience in helping me come up with a solution. I'm very happy with the results!

Malcolm
Malcolm Greene
Brooks-Durham
mgreene@bdurham.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform