Jump to content
  • Advertisement
Sign in to follow this  
Jannes

Sending Messages to CFrameWnd

This topic is 4970 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
Advertisement
Your handler isn't registered.

ON_REGISTERED_MESSAGE(YOURMSG, onYOURMSG)

Share this post


Link to post
Share on other sites
That causes a compile error because it would pass a CFrameWnd member not a CWnd member i think.

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
Quote:
Original post by Jannes
That did it, thanks alot. Stupid me.
Don't feel stupid, you'll learn by the time.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!