• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 843
  • Last Modified:

Dialog Window

I have dialog with 2 buttons. When I click on button1 a modeless window (windows1)should open in a paritcular position and when i click button2 another modeless window(window2) should open. But when I click button2 windows1 is not getting replaced with windows2. Please refer the code below and tell me i can i do this

void CTestDlg::OnButton1()
{
            
CModless1 *dlg = new CModless1 ();
dlg->Create(IDD_FORMVIEW,this);
dlg->ShowWindow(SW_SHOW);
dlg->SetWindowPos(0,100,0,0,0,SWP_NOSIZE|SWP_SHOWWINDOW);


}

void CTestDlg::OnButton2()
{
CModless2 *dlg = new CModless2 ();
dlg->Create(IDD_FORMVIEW1,this);
dlg->ShowWindow(SW_SHOW);
dlg->SetWindowPos(0,100,0,0,0,SWP_NOSIZE|SWP_SHOWWINDOW);
}
0
Gopakumar
Asked:
Gopakumar
1 Solution
 
AliYatesCommented:
You weren't ever destroying the windows you had created. Try using the same variable for both windows.

static CModless1 *dlg = NULL;

void CTestDlg::OnButton1()
{
if (dlg) delete (dlg);          
dlg = new CModless1 ();
dlg->Create(IDD_FORMVIEW,this);
dlg->ShowWindow(SW_SHOW);
dlg->SetWindowPos(0,100,0,0,0,SWP_NOSIZE|SWP_SHOWWINDOW);


}

void CTestDlg::OnButton2()
{
if (dlg) delete (dlg);          
dlg = new CModless2 ();
dlg->Create(IDD_FORMVIEW1,this);
dlg->ShowWindow(SW_SHOW);
dlg->SetWindowPos(0,100,0,0,0,SWP_NOSIZE|SWP_SHOWWINDOW);
}
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now