Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Possible to move the mouse cursor to text cursor positio
Message
De
01/11/2001 07:11:12
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
31/10/2001 14:38:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00575779
Message ID:
00576050
Vues:
32
Malcolm,
It's not you, me not understanding clearly what you want - you want a 'follower' :) I haven't seen Ed and George's replies and I think they already gave this solution to you (or similar) :
*Form.load && DLL, lib declarations
declare short GetCaretPos in win32API string @ lpPoint
declare short ClientToScreen in win32Api integer hWnd, string @ lpPoint
declare SetCursorPos in win32API integer X, integer Y
set library to home()+'foxtools.fll' additive

*Where you need the follower - keypress, interactivechange etc
Local lpPos, lnWHND, lnX,lnY,lnScreenX,lnScreenY
Store 0 to lnX,lnY,lnScreenX,lnScreenY
lpPos = space(8)
lnHWND =  _WhToHwnd(_WOnTop())

GetCaretPos(@lpPos) && Get text insertion point coordinates - in terms of form
For ix=1 to 8   && Decode 2 long values (X and Y)
  If ix<5
    lnX = lnX + asc(substr(lpPos,ix))*256^(ix-1)
  Else
    lnY = lnY + asc(substr(lpPos,ix))*256^(ix-5)
  Endif
Endfor
ClientToScreen(lnHWND, @ lpPos) && Convert client coords to screen coords
For ix=1 to 8
  If ix<5
    lnScreenX = lnScreenX + asc(substr(lpPos,ix))*256^(ix-1)
  Else
    lnScreenY = lnScreenY + asc(substr(lpPos,ix))*256^(ix-5)
  Endif
Endfor
SetCursorPos(lnScreenX,lnScreenY) && Set mouse pos to coords
Set message to 'CurX:'+trans(lnX)+'   CurY:'+trans(lnY) && Line-Col in statbar
Actually I think you don't need the part that moves mouse cursor to text cursor since what you need is coordinates to pop something ? If so code would end at line before ClientToScreen.

PS: Probably his would be needed in more than one forms\controls. Then I would create a custom class (declaring dlls and returning-setting pos via methods).
Cetin

>Cetin,
>
>I have studied your reply and I still remain clueless. I must be suffering from a major case of the 'stupids' today because you, Ed, and George have all posted what seem to be very matter of fact answers that for some reason just don't click with me.
>
>Here's my scenario: I have an edit box with lots of text. The user has paged down several pages worth of content in the edit box and is in the midst of editing their text. For example, their text cursor may currently be located 48 pixels down and 120 pixels to the right of the control's origin. I would like to determine where the user's text cursor is (relative to the current control, form or screen) so I can popup a 'smart tag' like window relative to their current text cursor position, i.e. up and to the right of the current text cursor position similar to how one might position a context menu via a right mouse click.
>
>I understand that _Screen.ActiveControl will tell me which control is active. I don't understand how I can use this information to synchronize my text cursor and mouse cursor so that they point at the same position on the screen.
>
>I understand that ObjToClient() will convert a control's position to coordinates relative to its form vs. container. Using this I can determine where my edit control is on a form. But I don't see a way for ObjToClient() DRILL DOWN INTO a control to determine the coordinates of the control's text cursor.
>
>I think(?) what I'm looking for is a way to use the 'mouse' command to move the mouse to a control's current text cursor position. Then I can query moues coordinates to determine the exact coordinates of a control's text cursor.
>
>Thank you for your help and patience.
>
>Regards,
>Malcolm
>
>
>>>Is there a way to move the mouse cursor to the position of a control's (textbox, editbox, combobox) text cursor so that both the text cursor and mouse cursor point to the same location on the screen?
>>>
>>>My motivation is that this technique would allow me to grab the location of a control's text cursor by retrieving the mouse's current coordinates.
>>>
>>>Thanks!
>>>Malcolm
>>
>>Malcolm,
>>Activecontrol would return you where text cursor (object) is and selstart position within cursor. You could also get form coordinates using ObjToClient()
>>Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform