Solved

Dialog Window

Posted on 2004-04-02
1
824 Views
Last Modified: 2008-02-26
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
Comment
Question by:Gopakumar
1 Comment
 

Accepted Solution

by:
AliYates earned 125 total points
ID: 10763958
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now