Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Enter button for several different actions
#1
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?
#2
Can you post an example dialog code please. Now I don't know exactly what is the problem.
#3
~removed my code~
#4
Try modeless dialog.

Replace the ShowDialog line to
Code:
Copy      Help
hDlg=ShowDialog("Example" &Example &controls 0 1 0 0 0 0 0 "dialog.ico" "Example")
MessageLoop

and under case WM_DESTROY add line
Code:
Copy      Help
,PostQuitMessage 0
#5
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
#6
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

Code:
Copy      Help
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
#7
Fantastic! I will try this.

Thanks again
#8
Worked like a charm!!!
#9
How do I "set disableKeyboard to 1 when you need"? BlockInput?
#10
,int disableKeyboard=0
,if m.message=WM_KEYDOWN and m.wParam=VK_RETURN
,,disableKeyboard=wintest(GetFocus "" "Internet Explorer_Server"); err
#11
WORKS PERFECT!!! Thank you Gin! I hope someday I can be even a fraction as good as you with this stuff. :mrgreen:


Forum Jump:


Users browsing this thread: 1 Guest(s)