Is there some reason why SetFocus won't work some time after calling ResetDialogAction?
I find that it does work when setting focus to a "normal" window's app, such as Calculator, however it does not work to set focus to a windowed DirectX program.
If I remove the call to ResetDialogAction, SetFocus then works fine. Of course then I can't interact with the dialog box.
I've tried using the window name as well as the handle (changing the value of WIN_USEHANDLE appropriately) with the same results.
I'd post a sample app, but my macro is almost 3000 lines long, and the test I wrote won't break, so perhaps there is some other interaction/bug going on.
Any ideas?
Problem with SetFocus after ResetDialogAction
Moderators: Dorian (MJT support), JRL
More info: if I leave the DirectX app's window title alone, it works fine.
However it breaks when I change the title via the call:
LibFunc>User32,SetWindowTextA,r,hwnd,NewTitle
No error is thrown by SetFocus, so it is finding the window, it's just not bringing it to the front. Also, it does work when the ResetDialogAction function is not used.
However it breaks when I change the title via the call:
LibFunc>User32,SetWindowTextA,r,hwnd,NewTitle
No error is thrown by SetFocus, so it is finding the window, it's just not bringing it to the front. Also, it does work when the ResetDialogAction function is not used.
I'm not sure how to resolve your problem but your last post reminded me of a phenomenon I noticed a while back. It appears that changing a dialog title using SetWindowTextA will only change the visible dialog title, it doesn't change the originally defined dialog. So resetting the dialog by using ResetDialogAction> will return the original title.
The following script will demonstrate. Pick the Change button and the dialog title will change. After a one second wait the script will execute a ResetDialogAction> and the original title will reappear.
Dialog>Dialog1
Caption=Original Title
Width=225
Height=130
Top=CENTER
Left=CENTER
Button=Change,72,56,75,25,3
EndDialog>Dialog1
Show>dialog1
Label>Loop
GetDialogAction>dialog1,res1
If>res1=2,EOF
If>res1=3,ChangeName
Wait>0.01
Goto>Loop
SRT>ChangeName
LibFunc>User32,SetWindowTextA,r,dialog1.handle,New Title
Wait>1
RDA>dialog1
END>ChangeName
Label>EOF
The following script will demonstrate. Pick the Change button and the dialog title will change. After a one second wait the script will execute a ResetDialogAction> and the original title will reappear.
Dialog>Dialog1
Caption=Original Title
Width=225
Height=130
Top=CENTER
Left=CENTER
Button=Change,72,56,75,25,3
EndDialog>Dialog1
Show>dialog1
Label>Loop
GetDialogAction>dialog1,res1
If>res1=2,EOF
If>res1=3,ChangeName
Wait>0.01
Goto>Loop
SRT>ChangeName
LibFunc>User32,SetWindowTextA,r,dialog1.handle,New Title
Wait>1
RDA>dialog1
END>ChangeName
Label>EOF
Thanks JRL.
I have gotten it working now if I use the window handles. I had been using GetWindowHandle, which didn't work. If I tried to get the handle BEFORE changing the title, there would be multiple windows with the same title and who knows which window would be retrieved. If I got the handle AFTER changing the title, I guess this is just broken as you mention. So, I switched to using GetActiveWindow and that works fine.
I can change the title of the window after retrieving the handle and it works, so this is fine.
Don't know why using the window titles themselves don't work, probably the same issue you mention.
Anyway, it's all good now.
I have gotten it working now if I use the window handles. I had been using GetWindowHandle, which didn't work. If I tried to get the handle BEFORE changing the title, there would be multiple windows with the same title and who knows which window would be retrieved. If I got the handle AFTER changing the title, I guess this is just broken as you mention. So, I switched to using GetActiveWindow and that works fine.
I can change the title of the window after retrieving the handle and it works, so this is fine.
Don't know why using the window titles themselves don't work, probably the same issue you mention.
Anyway, it's all good now.