SetFocus from OnInitDialog for Button control.
-
Hi, I my application(MFC dialog based),initially i have to put the focus on specified button control. i.e.Suppose my dialog having Three buttons 1.OK,2,Cancel,3.Button1.Initially i have to put focus on Button1, if user clicked Enter key the Button1 message handler will call. for this i tried like this. 1.CMyTestDlg::OnInitDialog() { GetDlgItem(IDC_BUTTON1)->SetFocus(); return FALSE;//Instead of TRUE } It showing correctly focus on Button1,But if i pressed enter key OnOK() is calling. Please help me inthis context. regards anju anju
-
Hi, I my application(MFC dialog based),initially i have to put the focus on specified button control. i.e.Suppose my dialog having Three buttons 1.OK,2,Cancel,3.Button1.Initially i have to put focus on Button1, if user clicked Enter key the Button1 message handler will call. for this i tried like this. 1.CMyTestDlg::OnInitDialog() { GetDlgItem(IDC_BUTTON1)->SetFocus(); return FALSE;//Instead of TRUE } It showing correctly focus on Button1,But if i pressed enter key OnOK() is calling. Please help me inthis context. regards anju anju
Hi, You don't have to setfocus() on OnInitDialog(), Try this one -- In design mode , go to Layout, choose Tab order, Click on the buttons that you want the tab order sequence. Run the application, -- Press Enter when the dialog shows up hope this might help you out
-
Hi, You don't have to setfocus() on OnInitDialog(), Try this one -- In design mode , go to Layout, choose Tab order, Click on the buttons that you want the tab order sequence. Run the application, -- Press Enter when the dialog shows up hope this might help you out
-
Hi SNathani, Thank you for your suggestion. Suppose, if my button is OwnerDrawn, what can i do? regards anju
It does not make any difference if the button is OwnerDrawn. You main problem will probably be that the OK button is set as the default button in the resource editor, you may need to clear this flag to get RETURN to act correctly on BUTTON1. Roger Allen Sonork 100.10016 Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
-
It does not make any difference if the button is OwnerDrawn. You main problem will probably be that the OK button is set as the default button in the resource editor, you may need to clear this flag to get RETURN to act correctly on BUTTON1. Roger Allen Sonork 100.10016 Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
-
Hi Roger Allen, Thanks for your reply. Already I cleared Ok button "default button" property. can you guess other thing. regards, anju
Rather than calling SetFocus(), you should call the following: GotoDlgCtrl(GetDlgItem(IDC_BUTTON1));