Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Derived class and SendMessage

19 views
Skip to first unread message

DanB

unread,
Feb 7, 2013, 2:45:35 PM2/7/13
to

Maybe someone has seen this before and just knows, I can't figure it so far.

So I have a class derived from CFrameWnd
class HERichFrame : public CFrameWnd

And then in a test app I derive like:
class CMainFrame : public HERichFrame


I want HERichFrame to handle certain things internally. So it has:

ON_MESSAGE( ID_VIEWSCROLL, OnViewScroll )
afx_msg LRESULT OnViewScroll( WPARAM par, LPARAM );

.cpp
LRESULT HERichFrame::OnViewScroll( WPARAM param, LPARAM )
{
return FALSE;
}

but OnViewScroll never gets called. Yet I can add the exact same handler
to CMainFrame and it does get called, so it should not be about my
handler or ID.

ON_MESSAGE( ID_VIEWSCROLL, OnViewScroll )
afx_msg LRESULT OnViewScroll( WPARAM par, LPARAM );

.cpp
LRESULT CMainFrame::OnViewScroll( WPARAM param, LPARAM )
{
return FALSE;
}


The call is from the child view.
GetParent( )->SendMessage( ID_VIEWSCROLL, nPos );


Baffled, Best, Dan.

ScottMcP [MVP]

unread,
Feb 7, 2013, 3:58:48 PM2/7/13
to
Check the class names that are in all of your BEGIN_MESSAGE_MAP statements. Those class names define the class derivation relationship for the message dispatching code. So in this statement:

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)

any message not handled by the CAboutDlg message map will be passed down to the CDialog message map.

DanB

unread,
Feb 7, 2013, 6:13:01 PM2/7/13
to
Hi Scott,
I thought of that and have. But it made me start to think and:
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CrtfParseDoc),
RUNTIME_CLASS(HERichFrame ),
RUNTIME_CLASS(CrtfParseView));

Instead of CMainFrame still had the problem. So the only thing I could
come up with was the:

#define ID_VIEWSCROLL ( WM_APP + 100 )

And found a second ID_VIEWSCROLL that didn't show on a search, or as a
warning, but with a different number! But when I opened that
'resource.h', it was there. That resource was a third resource in my
global includes, it should not have been there, I renamed it as
'junk.h'. What should have been my one and only define in globals should
have been in my 'heres.h'.

BTW, all my #include "resource.h" where that and not #include
<resource.h>, so I'm not sure why it got dug up.

Now that I ditched that extra resource.h it works fine.

Thanks for your time.

Best, Dan.

0 new messages