I need to specially handle painting messages, in particular WM_NCPAINT, in my frame windows/dialogs. For this reason, I am trying to use a special class that handles just these messages:
class CPaintHandler : public CCmdTarget
CPaintHandler( CWnd* pwndTarget);
virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
BOOL CPaintHandler::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
switch ( nID )
ASSERT ( FALSE );
// Dialog app calling code:
// Assume m_pPaintHandler is a CPaintHandler, constructed with "this" via DialogAppDlg::OnInitDialog().
BOOL DialogAppDlg::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
BOOL bRet = m_pPaintHandler ? m_pPaintHandler->OnCmdMsg ( nID, nCode, pExtra, pHandlerInfo ) : FALSE;
if ( !bRet )
bRet = CDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
As you can see, I have added a dummy handler into my CPaintHandler class for the WM_NCPAINT message. However, this is never getting called.
Now, I looked into OnCmdMsg, and found that it only deals with the handling of command user-interface objects. This is hence probably why I am not getting CPaintHandler::OnCmdMsg() called.
I cannot see another way around this however.
Can anyone suggest a fix please?
Thanks in advance.