|
-
February 3rd, 2009, 09:58 AM
#16
Re: Hide ahd Show Dialog
 Originally Posted by ajbharani
Something like this
Code:
void CDialog1::OnButton1()
{
CDialog2 *dia2 = new CDialog2();
dia2->Create(IDD_DIALOG2);
dia2->ShowWindow(SW_SHOW);
}
No, not like that, if you don't want to leak memory. Make the pointer to the dialog a member of the class.
Code:
class CDialog1
{
CDialog2 *m_dia2;
};
CDialog1::CDialog1()
{
m_dia2 = NULL;
}
void CDialog1::OnButton1()
{
if(m_dia2 == NULL)
m_dia2 = new CDialog2();
if(!m_dia2->Create(IDD_DIALOG2))
{
delete m_dia2;
m_dia2 = NULL;
// show error
}
m_dia2->ShowWindow(SW_SHOW); // or perhaps first call SW_SHOW and second call SW_HIDE
}
-
February 4th, 2009, 12:01 AM
#17
Re: Hide ahd Show Dialog
 Originally Posted by cilu
No, not like that, if you don't want to leak memory. Make the pointer to the dialog a member of the class.
Code:
class CDialog1
{
CDialog2 *m_dia2;
};
CDialog1::CDialog1()
{
m_dia2 = NULL;
}
void CDialog1::OnButton1()
{
if(m_dia2 == NULL)
m_dia2 = new CDialog2();
if(!m_dia2->Create(IDD_DIALOG2))
{
delete m_dia2;
m_dia2 = NULL;
// show error
}
m_dia2->ShowWindow(SW_SHOW); // or perhaps first call SW_SHOW and second call SW_HIDE
}
Ok. Nice piece of information. Thnks
Rate the posts which you find useful
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|