Is it Modeless or Modal dialog. I'm confused
-
Hi As far as I know there are two types of dialogs. Modeless and Modal. Now according what it says here : [url]http://www.devarticles.com/c/a/Cplusplus/Using-MFC-in-Cplus-Dialog-Boxes/4/\[/url\] and also on Microsft's MSDN site that to create Modeless dialog I must call Create() function and DestroyWindow() function. Whereas for the modal dialog I only call DoModal. Now I am confused as my dialog does not call any of those functions and I am still able to display it. The dialog initialization is: BOOL CProgressDlg::OnInitDialog() { CDialog::OnInitDialog(); ShowWindow(SW_HIDE); // Show or hide a control, etc. return TRUE; } and to display I call ShowWindow(SW_SHOW); and Close() function to close dialog: void CProgressDlg::Close() { EndDialog(IDOK); } It works.! So what kind of dialog is this? I guess this is a modeless dialog as it doesnt need to wait untill the user presses OK button. Is it correct what I am doing here or its wrong? Please let me know. My second question: The dialog I created is used to display a progress bar while some text files are processed using a separate worker thread (thread used purely for files processing not for the dialog). The problem I have is when I start processing files the dialog with the progress bar appears but its behind the main window. How can I force it to display over the main window as the modal dialogs do? I guess WS_OVERLAPPED will do but where to use it?
-
Hi As far as I know there are two types of dialogs. Modeless and Modal. Now according what it says here : [url]http://www.devarticles.com/c/a/Cplusplus/Using-MFC-in-Cplus-Dialog-Boxes/4/\[/url\] and also on Microsft's MSDN site that to create Modeless dialog I must call Create() function and DestroyWindow() function. Whereas for the modal dialog I only call DoModal. Now I am confused as my dialog does not call any of those functions and I am still able to display it. The dialog initialization is: BOOL CProgressDlg::OnInitDialog() { CDialog::OnInitDialog(); ShowWindow(SW_HIDE); // Show or hide a control, etc. return TRUE; } and to display I call ShowWindow(SW_SHOW); and Close() function to close dialog: void CProgressDlg::Close() { EndDialog(IDOK); } It works.! So what kind of dialog is this? I guess this is a modeless dialog as it doesnt need to wait untill the user presses OK button. Is it correct what I am doing here or its wrong? Please let me know. My second question: The dialog I created is used to display a progress bar while some text files are processed using a separate worker thread (thread used purely for files processing not for the dialog). The problem I have is when I start processing files the dialog with the progress bar appears but its behind the main window. How can I force it to display over the main window as the modal dialogs do? I guess WS_OVERLAPPED will do but where to use it?
How are you creating your dialog object? Modal's are (usually) created on the stack (or heap):
CMyDialog myDlg;
myDlg.DoModal() // Display a modal dialogWhen it goes out of scope, everything is cleaned up automagically...(if created on the stack) robert_s wrote: Now I am confused as my dialog does not call any of those functions and I am still able to display it. Now I am confused...how are you creating a dialog if your no calling Create or DoModal??? :confused: robert_s wrote: My second question: The dialog I created is used to display a progress bar while some text files are processed using a separate worker thread (thread used purely for files processing not for the dialog). The problem I have is when I start processing files the dialog with the progress bar appears but its behind the main window. How can I force it to display over the main window as the modal dialogs do? I guess WS_OVERLAPPED will do but where to use it?
SetForegroundWindow()
??? How do I print my voice mail?