- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a API project which has a dialog with several edit boxes and OK & Cancel buttons.
I have programmed it so that if the user pressed Return on an edit box the focus moves to the next field.
On the last field pressing retun passes focus to the OK button which is displayed with a dotted line round it. If I press Return nothing happens, but if I click on OK I get a response.
Is there something that I am missing?
I have tried renaming IDOK to my own ID name.
I have noticed that the control id I get back on pressing return on the OK button is the same as on the previous edit box.
Thanks,
David
I have programmed it so that if the user pressed Return on an edit box the focus moves to the next field.
On the last field pressing retun passes focus to the OK button which is displayed with a dotted line round it. If I press Return nothing happens, but if I click on OK I get a response.
Is there something that I am missing?
I have tried renaming IDOK to my own ID name.
I have noticed that the control id I get back on pressing return on the OK button is the same as on the previous edit box.
Thanks,
David
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You don't say how you are setting the focus to the next control. There are 'Windows issues' that cause SetFocus to misbehave; using PostMessage with the WM_NEXTDLGCTL message is safer, e.g.
hwnd=GetDlgItem(dlg%hwnd,IDC_OK)
lret=PostMesage(dlg%hwnd,WM_NEXTDLGCTL,hwnd,TRUE)
should set the focus to the OK button (with id IDC_OK used in dialog dlg) such that it will respond when the Return key is pressed. (PostMessage is defined in the module user32, TRUE is declared as = 1 in module dfwinty which I think is used in module dflogm.)
hwnd=GetDlgItem(dlg%hwnd,IDC_OK)
lret=PostMesage(dlg%hwnd,WM_NEXTDLGCTL,hwnd,TRUE)
should set the focus to the OK button (with id IDC_OK used in dialog dlg) such that it will respond when the Return key is pressed. (PostMessage is defined in the module user32, TRUE is declared as = 1 in module dfwinty which I think is used in module dflogm.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, I replaced SetFocus with the call with WM_NEXTDLGCTL and it worked.
By the way, is there a difference between PostMessage and SendMessage?
David
By the way, is there a difference between PostMessage and SendMessage?
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message. The PostMessage function, in contrast, posts a message to a thread's message queue and returns immediately."
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page