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 dialog trouble

modeless dialog trouble

Scheduled Pinned Locked Moved C / C++ / MFC
questionjavascripttutorial
7 Posts 4 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.
  • R Offline
    R Offline
    ryuki
    wrote on last edited by
    #1

    I've created 2 classes with baseclass CDialog. The first class should show the other dialog while working. I've done it that way: void CTestDlg::OnTest() { UpdateData(TRUE); CWaitDialog *wd=new CWaitDialog; if (!::IsWindow(wd->GetSafeHwnd())) wd->Create(IDD_DIALOG2, this); wd->ShowWindow(SW_SHOW); // work to do wd->EndDialog(0); wd=NULL; // some clearing UpdateData(FALSE); delete wd; } The second dialog shows up, but I can not move it or it doesn't react on input. When I show the dialog only without letting the first dialog do his work the second reacts as expected. So my question is how to create modeless windows like the one when copying or saving files? I think of the typical "work in progess" dialogs, showing the effort and let you quit the action.

    C D S 3 Replies Last reply
    0
    • R ryuki

      I've created 2 classes with baseclass CDialog. The first class should show the other dialog while working. I've done it that way: void CTestDlg::OnTest() { UpdateData(TRUE); CWaitDialog *wd=new CWaitDialog; if (!::IsWindow(wd->GetSafeHwnd())) wd->Create(IDD_DIALOG2, this); wd->ShowWindow(SW_SHOW); // work to do wd->EndDialog(0); wd=NULL; // some clearing UpdateData(FALSE); delete wd; } The second dialog shows up, but I can not move it or it doesn't react on input. When I show the dialog only without letting the first dialog do his work the second reacts as expected. So my question is how to create modeless windows like the one when copying or saving files? I think of the typical "work in progess" dialogs, showing the effort and let you quit the action.

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      you could try doing some message pumping in the "word to do" section. it could be that the modeless dialog is never given a chance to process any windows messages. Software | Cleek

      R 1 Reply Last reply
      0
      • R ryuki

        I've created 2 classes with baseclass CDialog. The first class should show the other dialog while working. I've done it that way: void CTestDlg::OnTest() { UpdateData(TRUE); CWaitDialog *wd=new CWaitDialog; if (!::IsWindow(wd->GetSafeHwnd())) wd->Create(IDD_DIALOG2, this); wd->ShowWindow(SW_SHOW); // work to do wd->EndDialog(0); wd=NULL; // some clearing UpdateData(FALSE); delete wd; } The second dialog shows up, but I can not move it or it doesn't react on input. When I show the dialog only without letting the first dialog do his work the second reacts as expected. So my question is how to create modeless windows like the one when copying or saving files? I think of the typical "work in progess" dialogs, showing the effort and let you quit the action.

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

        ryuki wrote: wd->EndDialog(0); EndDialog() is specific to modal dialog boxes.


        "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

        1 Reply Last reply
        0
        • C Chris Losinger

          you could try doing some message pumping in the "word to do" section. it could be that the modeless dialog is never given a chance to process any windows messages. Software | Cleek

          R Offline
          R Offline
          ryuki
          wrote on last edited by
          #4

          It might be the reason. Since I'm not very familiar with that topic, any recommends?

          C 1 Reply Last reply
          0
          • R ryuki

            It might be the reason. Since I'm not very familiar with that topic, any recommends?

            C Offline
            C Offline
            Chris Losinger
            wrote on last edited by
            #5

            here's a basic MsgPump function: void MsgPump(DWORD dwLen /* =200 */) { MSG m_msgCur; // current message CWinApp *pWinApp = AfxGetApp(); DWORD dInitTime = GetTickCount(); while (::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE) && (GetTickCount() - dInitTime < dwLen) ) { pWinApp->PumpMessage(); } } Call this periodically in the code where you do your work. You don't have to call it all the time, just once in a while. The dwLen is the number of ticks to wait. 200 is a good default. -c Software | Cleek

            R 1 Reply Last reply
            0
            • R ryuki

              I've created 2 classes with baseclass CDialog. The first class should show the other dialog while working. I've done it that way: void CTestDlg::OnTest() { UpdateData(TRUE); CWaitDialog *wd=new CWaitDialog; if (!::IsWindow(wd->GetSafeHwnd())) wd->Create(IDD_DIALOG2, this); wd->ShowWindow(SW_SHOW); // work to do wd->EndDialog(0); wd=NULL; // some clearing UpdateData(FALSE); delete wd; } The second dialog shows up, but I can not move it or it doesn't react on input. When I show the dialog only without letting the first dialog do his work the second reacts as expected. So my question is how to create modeless windows like the one when copying or saving files? I think of the typical "work in progess" dialogs, showing the effort and let you quit the action.

              S Offline
              S Offline
              Stlan
              wrote on last edited by
              #6

              Alternatively to the message pump, you can create a worker thread to do your job. There are some excellent articles in CodeProject about it (here for instance)

              1 Reply Last reply
              0
              • C Chris Losinger

                here's a basic MsgPump function: void MsgPump(DWORD dwLen /* =200 */) { MSG m_msgCur; // current message CWinApp *pWinApp = AfxGetApp(); DWORD dInitTime = GetTickCount(); while (::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE) && (GetTickCount() - dInitTime < dwLen) ) { pWinApp->PumpMessage(); } } Call this periodically in the code where you do your work. You don't have to call it all the time, just once in a while. The dwLen is the number of ticks to wait. 200 is a good default. -c Software | Cleek

                R Offline
                R Offline
                ryuki
                wrote on last edited by
                #7

                Thank you! It worked perfect. Even when dwLen=1 it is enough to make the second dialog accessable.

                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