Changing focus in an MFC Application
Hi all,
In my MFC application, the whole application is a modal dialog box and on the press of enter key I want to change focus from one control to the other ..in short I want to sinulate the tab key with enter key ....
my application is only this dialog box and in dialog boxes, enter should close them but in my application enter should meen the confirmation of the user input so I am planning to simulate enter through tab.
on the default button's click event I am
writing ......
Code:
void CPIVSyncDlg::OnBnClickedDummy()
{
//these two are edit controls from which I want to remove focus
SendDlgItemMessage(IDC_PDINPUT,WM_KILLFOCUS,IDC_STARTSTOP,0);
SendDlgItemMessage(IDC_QSWITCHREP,WM_KILLFOCUS,IDC_STARTSTOP,0);
//this is a button control on which I want o set the focus
SendDlgItemMessage(IDC_STARTSTOP,WM_SETFOCUS,(WPARAM)GetFocus(),0);
}
this gives me a very strange behaviour, i.e. after the focus has been shifted to the next control, I cannot select text or set the mouse cursor on the edit control which has lost the focus until I press a tab key..