|
-
October 21st, 1999, 05:20 AM
#1
open two modal dialog box
Hi!
This is my problem:
I have a MDI application when a general menu.
When the user clicks on an item of the menu, a dialog box appears. In this dialog box, there is a button and when the user clicks on it a second dialog box appears.
Sometimes, i want that when the clicks on an item of the menu i want that the first box appears and after the second.
I don't know how do that!
How can i "say" to the first dialog box, when it's displayed, to open the second dialog box as if the user clicks on the button?
Thanks for your help
Sandrine
-
October 21st, 1999, 05:33 AM
#2
Re: open two modal dialog box
Hi
eric33 again
i think i understand the problem and i have a somehow solution.
Declare a flag. In normal mode initialize the flag to false and if you want the two boxes to be opened put the flag to true.
The in the OnInitDialog of the first dialogbox open the second one if the flag is true.
Simple no ?
hop this helps
-
October 21st, 1999, 07:06 AM
#3
Re: open two modal dialog box
Hi Eric!!!
How are you?...
Thank for you help but i did what you advised me to do and it doesn't work! The problem is, if you put the instruction to open the second box in the OnInitDialog function of the first box, the second box appears but not the first.The first will appear when you close the second. It's logical: The system wait for the second box to be closed .
I want the first appears under the second!!!!
May be there is another way to resolve my problem.
This is the complete scenario: the 2 boxes are opened. The user clicks on a button and the 2 boxes disappear. And anywhere the user clicks i want that the 2 boxes appears.
So, my question is: is it possible to retrieve something ( pointer, handle ) of the two last opened windows and to display them?
Thanks for your help
Sandrine
-
October 21st, 1999, 07:40 AM
#4
Re: open two modal dialog box
Ok sandrine
So you have two problems.
Opening the two dialog boxes once
Closing the two dialog boxes once
I found a somehow solution for opening the boxes.
It is like the first one but using the WM_SHOW_WINDOW and WM_TIMER messages.
In fact in the OnShowWindow i redraw the window and then launch a very fast timer.
The timer event open the second dialog.
In this case the two boxes are opened and showed (BUT ONLY THE LAST CAN TAKE THE FOCUS). The result is very fast and quite good.
For closing the boxes you just have to get the pointer to the dialog and use either onok or oncancel methods.
here is a sample
// Pointers to dialogs
// Must not be CDialog * pointers because OnOk and OnCancel are private virtual functions
CMyDialog1 *dlg1=NULL;
CMyDialog2 *dlg2=NULL;
// Showing the first
CMyDialog1 firstdlg;
dlg1=&firstdlg;
firstdlg.m_secondDlg=true; // Flag to open the second one
firstdlg.DoModal();
// OnShowWindow
BOOL CMyDialog1::OnShowWindow() {
CDialog::OnShowWindow(bShow, nStatus);
// Launch rapid timer
if ( m_secondDlg )
SetTimer(1,1,NULL);
return TRUE;
}
// Timer
void CMyDialog1::OnTimer(UINT nIDEvent) {
if ( nIDEvent==1 ) {
KillTimer(1); // Dont forget (try if you want to know why ...)
CMyDialog2 seconddlg;
dlg2=&seconddlg;
seconddlg.DoModal();
return;
}
CDialog::OnTimer(nIDEvent);
}
// Close the two dialog
if ( dlg1 ) {
dlg1->OnOk();
dlg1=NULL;
}
if ( dlg2 ) {
dlg2->OnOk();
dlg2=NULL;
}
-
October 21st, 1999, 08:03 AM
#5
Re: open two modal dialog box
I try immediatly what you send me.
I believe you have resolved my problem!
Just a question: the DoModal() calls the OnInitDialog function and after is called the OnShowWindow() function?
Thanks a lot
Sandrine
Do you remenber to my problem of crash with the SetDlgItemText()? I worked on an old version, added step by step the new function, correcting some errors and changing names of my ID controls. And now i have no problem, no access violation message!! I don't know what was exactly the problem...
-
October 21st, 1999, 08:44 AM
#6
Re: open two modal dialog box
Yes there is no problem.
The first box will be displayed before the second is opened.
-
October 21st, 1999, 02:32 PM
#7
Re: open two modal dialog box
Hi,
Have you tryed using threads? You could set it up so that before the first dialog is oppened a thread will go out and open up the second and the main program thread will open up the first.
Use AfxBeginThread( thread ) and etc...
UINT DialogThread(LPVOID WinObjPtr)
{
CYourDialog dlg;
dlg.DoModal();
}
--Josh
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
|