I have a dialog where in depending on the selection from a combo box,
the controls below are going to be different. For doing this I have
put a static control in the place where I am going to show different
controls. I have created different dialog templates for each option.
Consider the case of particular option, say "MySQL". Corresponding to
this option, there is a dialog in resource, the style of which is
child and no border. I have added a class for this dialog called
CMySQLDialog. Inside CMySQLDialog there is a function called
CreateFromStatic which takes parent and ID as parameters. What I do is
create an object of CMySQLDialog inside the main dialog, say
m_mysql_dlg and then call m_mysql_dlg.CreateFromStatic(this,
IDC_STATIC1). Here IDC_STATIC1 is the ID of static control I have
placed in main dialog. Below is the code for CreateFromStatic
BOOL CMySQLDialog::CreateFromStatic(CDialog* pParent, UINT nID)
{
ASSERT_VALID(pParent);
CWnd* pWnd = pParent->GetDlgItem(nID); // Don't look, Joe!
if (!pWnd)
return FALSE;
if (Create(IDD, pParent))
{
CRect rc;
SetDlgCtrlID(nID);
pWnd->GetWindowRect(&rc);
pParent->ScreenToClient(&rc);
SetWindowPos(
pWnd,
rc.left,
rc.top,
0,
0,
SWP_NOSIZE);
ModifyStyle(0,WS_TABSTOP);
}
pWnd->DestroyWindow();
return (IsWindow(m_hWnd));
}
Everything works fine. When I change the option, different dialogs are
shown below.
Now the problem is how to set the TAB_STOP. On the main dialog there
is one combo and two buttons. On hitting tab the focus keeps moving
between only these three controls and never enters the child dialog
within, though I have set the style for child dialog as WS_TABSTOP.
What I want is on hitting tab the focus should move to combo box..then
on hitting again it should enter the child dialog....move inside all
controls within...on hitting the tab from last control within child
dialog, it should leave the child dialog and should focus on the next
control on main dialog,i.e the button.
How can I acheive this.
vadi