Hello - I'm reusing a modal dialog inside a loop with resetdialogaction.
The first time the dialog is executed the cursor begins in the first field/object as expected based on the order of objects in the dialog.
From the second pass onward, the cursor starts off in whatever the LAST field/object that was entered at the time the OK button was pressed in the PREVIOUS iteration.
Is there any way to reset or force the cursor back to the first field/object in the dialog on each modal pass?
Thanks a million for any help.
Take Care... Mike.
Control First Field/Object during Dialog reuse/loop
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Do this:
LibFunc>User32,SetFocus,r,Dialog1.msEdit1.Handle
Replace Dialog1.msEdit1.Handle with the handle variable for the object in question.
If you debug step past your Dialog> block you'll notice in the watch list that a number of variables are created all ending in .HANDLE. These variables store the handle of each of the objects. E.g.
Dialog1.Handle
Dialog1.msButton0.Handle
Dialog1.MyEdit.Handle
etc.
LibFunc>User32,SetFocus,r,Dialog1.msEdit1.Handle
Replace Dialog1.msEdit1.Handle with the handle variable for the object in question.
If you debug step past your Dialog> block you'll notice in the watch list that a number of variables are created all ending in .HANDLE. These variables store the handle of each of the objects. E.g.
Dialog1.Handle
Dialog1.msButton0.Handle
Dialog1.MyEdit.Handle
etc.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Hi Marcus!
Thanks for this - it works great on the SECOND pass (the cursor is positioned in the first object of the dialog as expected), but on the third pass the dialog "locks up". It's not in a loop (I checked the windows task manager), but it will only accept 1 character really quickly and the locks out all other keyboard entry (including shift-esc - I have to kill the msched task from the windows task manager).
This is the first time I've directly used the user32 lib in any script.
Thanks again for any help!
Take Care... Mike.
Thanks for this - it works great on the SECOND pass (the cursor is positioned in the first object of the dialog as expected), but on the third pass the dialog "locks up". It's not in a loop (I checked the windows task manager), but it will only accept 1 character really quickly and the locks out all other keyboard entry (including shift-esc - I have to kill the msched task from the windows task manager).
This is the first time I've directly used the user32 lib in any script.
Thanks again for any help!
Take Care... Mike.
Hi Mike,
I wrote a little script that confirmed your issue. Tried lots of things to make this work and finally added a show>dialog1 ahead of the libfunc> and a closedialog>dialog1 immediately following so that the dialog is actually open when the setfocus takes place and that seemed to eliminate the lockup. This may not actually resolve the issue but it seems to be a way to get around it.
Hope this helps,
Dick
I wrote a little script that confirmed your issue. Tried lots of things to make this work and finally added a show>dialog1 ahead of the libfunc> and a closedialog>dialog1 immediately following so that the dialog is actually open when the setfocus takes place and that seemed to eliminate the lockup. This may not actually resolve the issue but it seems to be a way to get around it.
Hope this helps,
Dick
Code: Select all
Dialog>Dialog1
Caption=Object focus test
Width=327
Height=126
Top=104
Left=16
Edit=msEdit1,16,8,281,
CheckBox=msCheckBox1,Enable Edit Object focus,80,40,153,True
Button=OK,116,64,75,25,3
EndDialog>Dialog1
Label>Loop
Show>dialog1,res1
Closedialog>dialog1
Wait>.2
If>res1=2,EOF
If>%dialog1.mscheckbox1%=True
//remark out the following line and the closedialog> line and the
//script will lock up the second time through.
Show>dialog1
LibFunc>User32,SetFocus,focres,Dialog1.msEdit1.Handle
Closedialog>dialog1
EndIf
//For some reason this Messagemodal> line will also prevent a lockup
//MDL>returned %focres%
Wait>.2
Let>res1=
Goto>Loop
Label>EOF