Solved

Dialog Window

Posted on 2004-04-02
1
827 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
topping2 challenge 13 90
Please explain: Aspect Oriented Programming 2 93
Tax Considerations for positive outcomes, outside the U.S. for IT Professionals 3 42
Help Required 3 96
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…
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

770 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