Re: MFC Desktop application, child window
Depends on how you want your child dialog to act.
If you need it to be modal then simply declare a variable of the dialogs
class type and call DoModal on it.
void CMyMainDlg::OnButtonClicked()
{
CChildDialog Dlg;
if (Dlg.DoModal() == IDOK)
{
m_Value = Dlg.GetValue();
}
}
Doing this will allow the user to only interact with the child dialog until
the child dialog is dismissed.
if you need the child dialog to be modeless thing become a little more
complicate. You will need to declare the variable in your class so that you
can destroy the window at some point. And instead of DoModal you have to
call the dialogs Create method instead
void CMyDialog::OnButtonClicked()
{
if (!m_ChildDialog.IsWindow())
{
m_ChildDialog.Create(CChildDialog::IDD,this);
}
m_ChildDialog.ShowWindow(SW_SHOW);
}
There are many examples of this on the internet. try looking for articles in
www.codeproject.com and www.codeguru.com
AliR.
"zack" <zack@discussions.microsoft.com> wrote in message
news:BBC4445F-6856-42C4-8F97-5B58504C11B2@microsoft.com...
Thanks AliR,
You realy help me ,
One thing i don't know is how to bring up the child dialog box,
and does all the cons of the main dialog class can get the values from the
child dialog,
I believe this is called inheritend the values.
thanks and regards
Zackm
"AliR (VC++ MVP)" wrote:
What part of that process are you having trouble with?
Use the AppWizard (File/New/Project/Visual C++/MFC/MFC Application) to
create a dialog based application.
Use the Resource Editor to place buttons on the dialog box.
Use the Resource Editor to create new dialogs to be your child dialogs.
Double Click on the Dialogs Titlebar, while they are open in the editor
to
create new MFC classes for the dialogs.
Double Click on the main dialogs button handler to create event handlers
for
them.
In the event handler bring up the dialog box.
AliR.
"zack" <zack@discussions.microsoft.com> wrote in message
news:CCEEB35A-BFB0-4684-8AAD-10CF59106333@microsoft.com...
hi ,
I have MFC application, Dialog based,Desktop application
and i would like to open child window,from a button in the main window
i would like to add free text input in the edit control
and child window with combo box control that i can recieve the data
after
the
user configuration.
Any code sample will help.
Thanks