Sign in to follow this  

Sending Messages to CFrameWnd

This topic is 4667 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone, i would like to send a user defined message to the MainFrame of my single-doc mfc app from the View. I want it to force loading of another main-toolbar resource, so i can use multiple toolbars (one at a time). How can this be done? I defined message: #define CHANGETOOLBAR_MESSAGE WM_APP+1 Added function to CMainFrame: afx_msg void OnCHANGETOOLBAR_MESSAGE(); and use this to send message in a member function of my View: AfxGetMainWnd()->SendMessage(CHANGETOOLBAR_MESSAGE); but nothing happens.

Share this post


Link to post
Share on other sites
Try the ON_MESSAGE macro instead. That would be to place:
ON_MESSAGE(CHANGETOOLBAR_MESSAGE, OnCHANGETOOLBAR_MESSAGE);
in your message map.

You don't need WM_APP+1 either. WM_APP is the first free message identification you can use.

Share this post


Link to post
Share on other sites
I tried it, but it gives me the same error:
error C2440: 'static_cast' : 'void (__thiscall CMainFrame::* )(void)' can not be converted to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'

Share this post


Link to post
Share on other sites
Quote:
Original post by Jannes
I tried it, but it gives me the same error:
error C2440: 'static_cast' : 'void (__thiscall CMainFrame::* )(void)' can not be converted to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
You have the wrong return type and arguments. It should be:
afx_msg LRESULT OnCHANGETOOLBAR_MESSAGE(WPARAM WParam, LPARAM LParam);

Share this post


Link to post
Share on other sites

This topic is 4667 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this