I also tried using a libfunc> technique described here. But I'm not certain I've altered it correctly for my application.
What I want to accomplish is to know which field a user is currently visiting and to perform a task based solely on the fact that the cursor is active in that field. I thought about using GetCursorPos> but that will fail if the user tabs through the dialog.
Here is a sample dialog with multiple fields, followed by another sample dialog that incorporates a test for GetCaretPos>:
Code: Select all
Dialog>Dialog1
Caption=Purchase Requisition
Width=291
Height=237
Top=174
Left=150
Max=1
Min=1
Close=0
Resize=1
Edit=msEdit1,80,0,121,msEdit1
Edit=msEdit2,80,24,121,msEdit2
Edit=msEdit3,80,48,121,msEdit3
Edit=msEdit4,80,72,121,msEdit4
Edit=msEdit5,80,96,121,msEdit5
Edit=msEdit6,80,120,121,msEdit6
Button=Close,96,168,75,25,2
EndDialog>Dialog1
Show>dialog1
Label>start
wait>0.5
GDA>dialog1,r1
If>r1=2,end
Goto>start
Label>end
Code: Select all
OnEvent>KEY_DOWN,VK1,0,KeyPress
OnEvent>WINDOW_NEWACTIVE,0,0,KeyPress
SRT>CPos
Show>dialogcp
Label>startcp
GDA>dialogcp,rcp
If>rcp=2,endcp
Wait>0.01
Goto>startcp
Label>endcp
END>CPos
SRT>KeyPress
Let>WIN_USEHANDLE=0
GAW>winname,winX,winY
//Let>WIN_USEHANDLE=0
//LibFunc>user32,FindWindowA,WinVar,Tedit,msEdit1
GTP>qX,qY,0
GTP>kX,kY,1
Let>deltaX=%qX%-%winX%
Let>deltaY=%qY%-%winY%
Let>dialogcp.mslabel0=Caret position rel= %kX%,%kY%%CRLF%Caret position absolute= %qX%,%qY%%CRLF%Caret position absolute-window pos= %deltaX%,%deltaY%%CRLF%Window Name= %winname%%CRLF%Window Position= %winX%,%winY%%CRLF%
RDA>dialogcp
END>KeyPress
Dialog>Dialogcp
Caption=Caret position
Width=230
Height=250
Top=288
Left=500
Close=0
Label=pick on a field of a window%CRLF%to see relative caret position,5,8
Button=Close,72,184,75,25,2
EndDialog>Dialogcp
Dialog>DialogPR
Caption=Purchase Requisition
Width=302
Height=304
Top=174
Left=150
Max=1
Min=1
Close=0
Resize=1
Edit=msEdit1,80,0,121,ms
Edit=msEdit2,80,24,121,msE
Edit=msEdit3,80,48,121,msEd
Edit=msEdit4,80,72,121,msEdi
Edit=msEdit5,80,96,121,msEdit
Edit=msEdit6,80,120,121,msEdit6
Memo=msMemo1,80,144,185,89,msMemo1
EndDialog>DialogPR
Show>DialogPR
Label>start
wait>0.5
GDA>DialogPR,r1
Gosub>CPos
If>rcp=2,end
Goto>start
Label>end
Any help will be appreciated,
Dick