Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

new biw : Problem in generating a child window

Status
Not open for further replies.

madhavilt

Programmer
Apr 10, 2003
7
IN

hi,
I am a newbie to PPC technology.Along with my learning, I am creating some sample applications.I tried to create one sample application to generate a child window by clicking a button"main" in main window.I followed one modeless sample given with SDK.
the code is :


void CMainDlg::OnMain()
{
// TODO: Add your control notification handler code here


CChilddlg* m_pchild;
m_pchild = NULL;
if(m_pchild == NULL) {
m_pchild = new CChilddlg(this);
if(m_pchild->Create(1,NULL) == TRUE)
GetDlgItem(IDC_MAIN)->EnableWindow(FALSE);
}
else
m_pchild->SetActiveWindow();

}

now m_pchild->Create(1,NULL) is returning false.and my application is returning nothing instead of generating a child window.
can any one please help me.

Thanks in advance,
madhavi

 
In the line Create(1,NULL)... the first parameter is supposed to be the ID of the dialog! You should set this to CChildDlg::IDD, which is a constant that represents the child dialog's ID.

--------------
And also:

m_pchild = NULL;
if(m_pchild == NULL) {

The preceding lines in your code are pointless.

Will
 
thanks for ur reply.I got my mistake.I did the required modifications still I am not getting.
this is the code :

void CMainDlg::OnMain()
{
// TODO: Add your control notification handler code here

if(m_pchild == NULL) {
AfxMessageBox(TEXT("no child window is active"));
m_pchild = new CChilddlg(this);
if(m_pchild->Create(IDD_CHILD_DIALOG,NULL) == TRUE)
GetDlgItem(IDC_MAIN)->EnableWindow(FALSE);
else AfxMessageBox(TEXT("FALSE : failed to create a child window"));
}
else {
AfxMessageBox(TEXT("Child window is active"));
m_pchild->SetActiveWindow();
}

}

just to check the control flow I kept messagebox.Now when I am, clicking on mian button, instead of generating a child window, message box is appearing with message "Child window is active" in the first step itself.

anyone please help where I did the mistake..

thanks in advance,
madhavi
 
m_pChild->ShowWindow(SW_SHOW) must be called unless the dialog resource has the WS_VISIBLE style
 
thanks alot for ur reply apatterno.Now it is working.
thanks,
madhavi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top