Posts: 82
Threads: 31
Joined: Oct 2007
I know how to attach the press of the enter button to a particular button in my dialog. I also know how to prevent the enter button from performing any action in my dialog. But now I'm running into a problem.. I have a multi page dialog. Some pages have a browser in it and others have messages, child dialogs, etc.. and each page has a url search bar at the top. The problem I'm having is, if you were to type in
www.google.com for instance you would normally hit enter to activate the "go" button. But, if you were typing in a search query into google search engine and hit enter, it would activate their search button. Or if a message pops up you could normally hit enter to activate the OK button. Etc... How can I allow the enter to work only with what I'm working with?
Posts: 12,073
Threads: 140
Joined: Dec 2002
Can you post an example dialog code please. Now I don't know exactly what is the problem.
Posts: 82
Threads: 31
Joined: Oct 2007
Posts: 12,073
Threads: 140
Joined: Dec 2002
Try modeless dialog.
Replace the ShowDialog line to
hDlg=ShowDialog("Example" &Example &controls 0 1 0 0 0 0 0 "dialog.ico" "Example")
MessageLoop
and under case WM_DESTROY add line
Posts: 82
Threads: 31
Joined: Oct 2007
That definately helped! It's no longer going to the last page of the dialog on enter. Still can't seem to get it to activate the "GO" button... I'll just have to play around and see if I can figure it out..
Thanks Gin
Posts: 12,073
Threads: 140
Joined: Dec 2002
In modeless dialogs, keyboard navigation does not work. Therefore key Enter does not press buttons. To enable Enter only in some conditions, replace the MessageLoop line to
MSG m
rep
,if(GetMessage(&m 0 0 0)<1) break
,int disableKeyboard
,;Add here code to set disableKeyboard to 1 when you need.
,;Or here you can catch WM_KEYDOWN messages and in certain conditions execute your code and continue.
,;example
,if m.message=WM_KEYDOWN and m.wParam=VK_RETURN
,,sel GetWinId(GetFocus)
,,,case 1104 but 1105 hDlg; continue ;;if pressed Enter in the address box, press Go button
,,,;case xxxx but yyyy; continue
,,,;...
,if(!disableKeyboard and IsDialogMessage(GetActiveWindow &m)) continue
,TranslateMessage &m
,DispatchMessage &m
Posts: 82
Threads: 31
Joined: Oct 2007
Fantastic! I will try this.
Thanks again
Posts: 82
Threads: 31
Joined: Oct 2007
Posts: 82
Threads: 31
Joined: Oct 2007
How do I "set disableKeyboard to 1 when you need"? BlockInput?
Posts: 12,073
Threads: 140
Joined: Dec 2002
,int disableKeyboard=0
,if m.message=WM_KEYDOWN and m.wParam=VK_RETURN
,,disableKeyboard=wintest(GetFocus "" "Internet Explorer_Server"); err
Posts: 82
Threads: 31
Joined: Oct 2007
WORKS PERFECT!!! Thank you Gin! I hope someday I can be even a fraction as good as you with this stuff. :mrgreen: