mridey
asked on
WTL - Use of CIdleHandler with CDialogImpl
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_INITDIA LOG, OnInitDialog)
COMMAND_ID_HANDLER(IDCANCE L, 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
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_INITDIA
COMMAND_ID_HANDLER(IDCANCE
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
-- Dan