Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

WTL - Use of CIdleHandler with CDialogImpl

Posted on 2002-03-19
2
Medium Priority
?
1,012 Views
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
{
public:
     enum { IDD = IDD_TEXT };

     BEGIN_MSG_MAP(CMcScanDlg)
          MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
          COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
     END_MSG_MAP()

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

          return TRUE;
     }

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

     BOOL OnIdle()
     {
          Beep(4000,100);
          return TRUE;
     }

};

and I call it using

CMcScanDlg dlg1;
dlg1.DoModal();

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 ?

Thanks
0
Comment
Question by:mridey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 49

Accepted Solution

by:
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
0
 
LVL 49

Expert Comment

by:DanRollins
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

636 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