WTL - Use of CIdleHandler with CDialogImpl

Posted on 2002-03-19
Medium Priority
Last Modified: 2013-11-25
This is a Windows Template Library question.

I would like to implement an Idle loop on a dialog.
I have:

class CMcScanDlg : public CDialogImpl<CMcScanDlg>, CIdleHandler
     enum { IDD = IDD_TEXT };


     LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
          CMessageLoop* pLoop = _Module.GetMessageLoop();
          ATLASSERT(pLoop != NULL);

          return TRUE;

     LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
          return 0;

     BOOL OnIdle()
          return TRUE;


and I call it using

CMcScanDlg dlg1;

But OnIdle() is never called, at least not during the DoModal(). It's only called once the code is back in the main application (and the main message loop).

Any clue ?

Question by:mridey
  • 2
LVL 49

Accepted Solution

DanRollins earned 600 total points
ID: 7043936
It's because it is a true 'DoModal'; that is, control passes to the system and does not return until the user dismisses the dialog.

MFC handles this by simulating DoModal -- the dialog box is actually a modeless dlg so it can micro-manage the message pump.

-- Dan
LVL 49

Expert Comment

ID: 7058252
Did you insult me with a C because of my race?  Gender bias?  I can't think of any other reason you would want to tarnish my otherwise 4.0 Grade Point Average.

-- Dan

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question