Wanting2LearnMan
asked on
Set MFC dialog focus?
If I have an MFC dialog and dynamically create controls on it e.g a tab control. How do I set focus on the main parent dialog afterwards?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK Thanks,
Can you tell me how to use this in my OnInitFunction?? InMy Oninit I create a tab control like so:
dlgTab1Dlg = new CTab1(this);
dlgTab1Dlg->Create(IDD_TAB 1_DIALOG, this);
dlgTab1Dlg->SetParent(&m_t abOptions) ;
dlgTab1Dlg->ShowWindow(SW_ SHOW);
dlgTab1Dlg->SetWindowPos(N ULL, rTab.left, rTab.top, rTab.Width(), rTab.Height(), SWP_NOZORDER);
dlgTab2Dlg = new CTab2(this);
dlgTab2Dlg->Create(IDD_TAB 2_DIALOG, this);
dlgTab2Dlg->SetParent(&m_t abOptions) ;
dlgTab2Dlg->ShowWindow(SW_ SHOW);
dlgTab2Dlg->SetWindowPos(N ULL, rTab.left, rTab.top, rTab.Width(), rTab.Height(), SWP_NOZORDER);
anf after this I want focus to go to my main dialog.
Can you tell me how to use this in my OnInitFunction?? InMy Oninit I create a tab control like so:
dlgTab1Dlg = new CTab1(this);
dlgTab1Dlg->Create(IDD_TAB
dlgTab1Dlg->SetParent(&m_t
dlgTab1Dlg->ShowWindow(SW_
dlgTab1Dlg->SetWindowPos(N
dlgTab2Dlg = new CTab2(this);
dlgTab2Dlg->Create(IDD_TAB
dlgTab2Dlg->SetParent(&m_t
dlgTab2Dlg->ShowWindow(SW_
dlgTab2Dlg->SetWindowPos(N
anf after this I want focus to go to my main dialog.
is the tab control the part of your main dialog.
if not, fetch the handle to the main dialog window.
then use
PostMessage with required LParam and WParam:
for example, check out:
http://www.softwareobjectives.com.au/VoConversion/Lists/VOTips/DispForm.aspx?ID=106
for details of message, check out:
http://msdn.microsoft.com/en-us/library/ms645432(VS.85).aspx
Do let me know if you have any queries.
James
if not, fetch the handle to the main dialog window.
then use
PostMessage with required LParam and WParam:
for example, check out:
http://www.softwareobjectives.com.au/VoConversion/Lists/VOTips/DispForm.aspx?ID=106
for details of message, check out:
http://msdn.microsoft.com/en-us/library/ms645432(VS.85).aspx
Do let me know if you have any queries.
James
James