Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Is it Modeless or Modal dialog. I'm confused

Is it Modeless or Modal dialog. I'm confused

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++comhelp
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    robert_s
    wrote on last edited by
    #1

    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?

    A 1 Reply Last reply
    0
    • R robert_s

      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?

      A Offline
      A Offline
      alex barylski
      wrote on last edited by
      #2

      How are you creating your dialog object? Modal's are (usually) created on the stack (or heap):

      CMyDialog myDlg;
      myDlg.DoModal() // Display a modal dialog

      When 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?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups