This is a related question to the one at http:Q_24437902.html
. I have a helper class whose job is to handle certain messages from a certain CWnd. I do this by setting a new WNDPROC via SetWindowLong (not shown). See code below:
// Handler for the WM_NCPAINT message
virtual LRESULT OnNcPaintHandler ( HRGN hUpdateRgn );
// Window whose WNDPROC we are replacing
// Replacement WNDPROC
static LRESULT CALLBACK CustomWndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM );
/*static*/ LRESULT CALLBACK CMyHelper::CustomWndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
CMyHelper* pHelper = ( CMyHelper*) GetProp ( hwnd, _T("HELPER") );
switch ( msg )
// Call handler for WM_NCPAINT
pHelper->OnNcPaintHandler ( ( HRGN ) wParam )
However, at the related question, ZOPPO has suggested that I derive CMyHelper from CWnd: that way, I can access the base class handler functions of the CWnd* that is passed in.
This has triggered a new thought: if I inherit from CWnd, I can have a message map. This would do away with the messy switch statement in CustomWndProc (above). The thing is, if I have
I cannot see how to wire up m_pWnd in CHelper to make use of this message map, instead of the message map it currently has. If I could, I could just have dummy one-liners handling the functions that forward the call onto the appropriate virtual function within CMyHelper: in the case of WM_NCPAINT, it would be OnNCPaintHandler.
Is what I am after possible?