how to display non modal dialog only one time?
I mean if it is alraady open the not to create the dialog.
Printable View
how to display non modal dialog only one time?
I mean if it is alraady open the not to create the dialog.
Are You using VC?
You just have to set Your Dlg-ptr to NULL (e.g. in the ctor) and then check, if it is valid:
(Don't forget to delete the ptr. in the dtor!)Code:if (!m_pDlg)
{
m_pDlg = new Dlg1;
m_pDlg->Create(IDD_DIALOG1, this);
}
m_pDlg->ShowWindow(SW_SHOW);
Is that what You want?
Mikey
And if you're using pure API (which would be better!) here's the equivalent code:
Code:HWND g_hDlg = NULL;
//...
if(!g_hDlg) {
g_hDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_YOURDIALOG), hwnd, DlgProc);
}
Thank U very much
if (!m_pDlg)
{
m_pDlg = new Dlg1;
m_pDlg->Create(IDD_DIALOG1, this);
}
m_pDlg->ShowWindow(SW_SHOW);
if (!&m_pDlg)
{
m_pDlg = new Dlg1;
m_pDlg->Create(IDD_DIALOG1, this);
}
m_pDlg->ShowWindow(SW_SHOW);
Both of these codes give error in if statement.
it works without pointer
if (!m_pDlg)
{
m_pDlg.Create(IDD_DIALOG1, this);
}
m_pDlg.ShowWindow(SW_SHOW);
but how to work using pointer?