CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2006
    Posts
    143

    OnIdle processing

    Hi,

    Just a simple question..A dialog based MFC application does not seem to handle OnIde() processing even if you override OnIdle(). But a SDI or MDI app does. Why is this so? Thanks in advance..

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: OnIdle processing

    It is by design of MFC: CWinApp::OnIdle and CWinApp::Run are called only after the CWinApp::InitInstance returns TRUE. But in a dialog based App InitInstance returns after the dialog exits, so it doesn't make any sense call Run nor OnIdle.
    Instead the dialog uses its own message loop (but without OnIdle). You can, however, implement you own "idle" processing using WM_KICKIDLE (or/and WM_IDLEUPDATECMDUI) message. See
    http://msdn.microsoft.com/en-us/magazine/cc301466.aspx
    http://www.microsoft.com/msj/0797/c0797.aspx
    Victor Nijegorodov

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: OnIdle processing

    Another approach could be to use the dialog modeless instead of running DoModal. This way the dialog becomes main window, with OnIdle available in application class. The attached sample provides minimal framework needed for such an app proper functioning.
    Attached Files Attached Files
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured