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. Modeless Dialogs

Modeless Dialogs

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
4 Posts 3 Posters 0 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.
  • J Offline
    J Offline
    Jay Hova
    wrote on last edited by
    #1

    Hi, I did a search on how to create a modeless dialog window and got some great things. I did follow one of the articles on how to do this, and it worked great for dialogs that pop up when choosing it from a menu. However, I also want to do the same thing when I click on an "OK" button of a modal dialog. Basically I want to close the modal and have the modeless dialog come up. I am using the code: void CSendTo::OnOK() { //CDialog::OnOK(); if (!m_pCommandOpt) m_pCommandOpt = new CMainCommand; if (!::IsWindow(m_pCommandOpt->GetSafeHwnd())) m_pCommandOpt->Create(IDD_MAIN_TAB_DIALOG, this); m_pCommandOpt->ShowWindow(SW_SHOWNORMAL); //CDialog::OnOK(); } If I remove the either of the comments in front of CDialog::OnOK() it closes both windows and only flashes the modeless window for a second on screen. If I leave it commented out it keeps the modal window on screen and pops up the second window which seems to be MODAL. If i close the second window the first window is still there MUCH THANKS IN ADVANCE!!!!

    V D 2 Replies Last reply
    0
    • J Jay Hova

      Hi, I did a search on how to create a modeless dialog window and got some great things. I did follow one of the articles on how to do this, and it worked great for dialogs that pop up when choosing it from a menu. However, I also want to do the same thing when I click on an "OK" button of a modal dialog. Basically I want to close the modal and have the modeless dialog come up. I am using the code: void CSendTo::OnOK() { //CDialog::OnOK(); if (!m_pCommandOpt) m_pCommandOpt = new CMainCommand; if (!::IsWindow(m_pCommandOpt->GetSafeHwnd())) m_pCommandOpt->Create(IDD_MAIN_TAB_DIALOG, this); m_pCommandOpt->ShowWindow(SW_SHOWNORMAL); //CDialog::OnOK(); } If I remove the either of the comments in front of CDialog::OnOK() it closes both windows and only flashes the modeless window for a second on screen. If I leave it commented out it keeps the modal window on screen and pops up the second window which seems to be MODAL. If i close the second window the first window is still there MUCH THANKS IN ADVANCE!!!!

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      There are several solutions. One solution is messages. In OnOK(), send a message to the modal dialog box parent and have it create a modeless dialog box. Kuphryn

      1 Reply Last reply
      0
      • J Jay Hova

        Hi, I did a search on how to create a modeless dialog window and got some great things. I did follow one of the articles on how to do this, and it worked great for dialogs that pop up when choosing it from a menu. However, I also want to do the same thing when I click on an "OK" button of a modal dialog. Basically I want to close the modal and have the modeless dialog come up. I am using the code: void CSendTo::OnOK() { //CDialog::OnOK(); if (!m_pCommandOpt) m_pCommandOpt = new CMainCommand; if (!::IsWindow(m_pCommandOpt->GetSafeHwnd())) m_pCommandOpt->Create(IDD_MAIN_TAB_DIALOG, this); m_pCommandOpt->ShowWindow(SW_SHOWNORMAL); //CDialog::OnOK(); } If I remove the either of the comments in front of CDialog::OnOK() it closes both windows and only flashes the modeless window for a second on screen. If I leave it commented out it keeps the modal window on screen and pops up the second window which seems to be MODAL. If i close the second window the first window is still there MUCH THANKS IN ADVANCE!!!!

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        I've never tried anything like this but so my suggestion may be way off. Perhaps the issue lies in the call to Create(). By specifying a parent, the child dialog goes away as soon as its parent goes away. Remove the 'this' parameter and note the results.

        J 1 Reply Last reply
        0
        • D David Crow

          I've never tried anything like this but so my suggestion may be way off. Perhaps the issue lies in the call to Create(). By specifying a parent, the child dialog goes away as soon as its parent goes away. Remove the 'this' parameter and note the results.

          J Offline
          J Offline
          Jay Hova
          wrote on last edited by
          #4

          Thanks for all your help. Looks like i don't need the window to be modeless anyways. BTW, David you were right! I feel so silly not even thinking about that. ;P Once again, thank you!

          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