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. How to use OnTimer in modeless Dialog?

How to use OnTimer in modeless Dialog?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
4 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.
  • H Offline
    H Offline
    hanlei0000000009
    wrote on last edited by
    #1

    // dialog BOOL dlgWait::OnInitDialog(void) { CDialog::OnInitDialog(); SetTimer(1,500, NULL); return TRUE; } void dlgWait::OnTimer(UINT_PTR nIDEvent) { AfxMessageBox("aaaa"); CDialog::OnTimer(nIDEvent); } dlgWait waitDlg; waitDlg.Create(IDD_DLG_WAIT,NULL); waitDlg.ShowWindow(SW_SHOW); // AfxMessageBox("aaaa"); would't display Sleep(10000); /* If change waitDlg.Create(IDD_DLG_WAIT,NULL); waitDlg.ShowWindow(SW_SHOW); to waitDlg.DoModal(); AfxMessageBox("aaaa"); would display */

    C R T 3 Replies Last reply
    0
    • H hanlei0000000009

      // dialog BOOL dlgWait::OnInitDialog(void) { CDialog::OnInitDialog(); SetTimer(1,500, NULL); return TRUE; } void dlgWait::OnTimer(UINT_PTR nIDEvent) { AfxMessageBox("aaaa"); CDialog::OnTimer(nIDEvent); } dlgWait waitDlg; waitDlg.Create(IDD_DLG_WAIT,NULL); waitDlg.ShowWindow(SW_SHOW); // AfxMessageBox("aaaa"); would't display Sleep(10000); /* If change waitDlg.Create(IDD_DLG_WAIT,NULL); waitDlg.ShowWindow(SW_SHOW); to waitDlg.DoModal(); AfxMessageBox("aaaa"); would display */

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      The problem is because of the Sleep(10000). By doing that, you prevent window messages to be processed, thus your timer message will only be processed after the sleep.

      Cédric Moonen Software developer
      Charting control [v1.4]

      1 Reply Last reply
      0
      • H hanlei0000000009

        // dialog BOOL dlgWait::OnInitDialog(void) { CDialog::OnInitDialog(); SetTimer(1,500, NULL); return TRUE; } void dlgWait::OnTimer(UINT_PTR nIDEvent) { AfxMessageBox("aaaa"); CDialog::OnTimer(nIDEvent); } dlgWait waitDlg; waitDlg.Create(IDD_DLG_WAIT,NULL); waitDlg.ShowWindow(SW_SHOW); // AfxMessageBox("aaaa"); would't display Sleep(10000); /* If change waitDlg.Create(IDD_DLG_WAIT,NULL); waitDlg.ShowWindow(SW_SHOW); to waitDlg.DoModal(); AfxMessageBox("aaaa"); would display */

        R Offline
        R Offline
        Rajkumar R
        wrote on last edited by
        #3

        hanlei0000000009 wrote:

        waitDlg.ShowWindow(SW_SHOW); // AfxMessageBox("aaaa"); would't display Sleep(10000);

        Sleep (10000); will block message pumping.

        1 Reply Last reply
        0
        • H hanlei0000000009

          // dialog BOOL dlgWait::OnInitDialog(void) { CDialog::OnInitDialog(); SetTimer(1,500, NULL); return TRUE; } void dlgWait::OnTimer(UINT_PTR nIDEvent) { AfxMessageBox("aaaa"); CDialog::OnTimer(nIDEvent); } dlgWait waitDlg; waitDlg.Create(IDD_DLG_WAIT,NULL); waitDlg.ShowWindow(SW_SHOW); // AfxMessageBox("aaaa"); would't display Sleep(10000); /* If change waitDlg.Create(IDD_DLG_WAIT,NULL); waitDlg.ShowWindow(SW_SHOW); to waitDlg.DoModal(); AfxMessageBox("aaaa"); would display */

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          hanlei0000000009 wrote:

          Sleep(10000);

          anyways why you require sleep(10000) here!

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
          Never mind - my own stupidity is the source of every "problem" - Mixture

          cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>

          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