Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 65759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:59:49+00:00 2026-05-10T18:59:49+00:00

I was just wondering what (if any) the difference was between the following two

  • 0

I was just wondering what (if any) the difference was between the following two message traps in MFC for the function, OnSize(..).

1 – Via Message map:

BEGIN_MESSAGE_MAP(CClassWnd, CBaseClassWnd) ...     ON_WM_SIZE() .. END_MESSAGE_MAP() 

2 – Via afx_message:

afx_msg type OnSize(...); 

They seem to be used interchangeably, which one should be used or does it depend on other factors?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:59:49+00:00Added an answer on May 10, 2026 at 6:59 pm

    Both parts are necessary to add a message handler to a class. The message map should be declared inside your class, together with declarations for any message handler functions (e.g, OnSize).

    class CClassWnd : public CBaseClassWnd {     ...     afx_msg void OnSize(UINT nType, int cx, int cy);     DECLARE_MESSAGE_MAP }; 

    afx_msg is just an empty placeholder macro – it doesn’t actually do anything, but is always included by convention.

    The message map is then defined in the class’s .cpp file:

    BEGIN_MESSAGE_MAP(CClassWnd, CBaseClassWnd)     ON_WM_SIZE() END_MESSAGE_MAP() 

    These macros generate a lookup table for the class which allows messages received by the window to be dispatched to the corresponding handler functions. The ON_WM_SIZE macro allows the wParam and lParam message parameters in the WM_SIZE message to be decoded into more meaningful values for the message handler function (nType, cx, and cy in this case). MFC provides macros for most window messages (WM_LBUTTONDOWN, WM_DESTROY, etc).

    You can find more information on how message maps work in MFC here on MSDN.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just wondering if there is any difference between the two different new
just wondering the difference between the presence of the last comma in the array,
I am wondering if there is any difference in runtime between a generic container
I am wondering whether there is any difference between inlining functions on a linker
The DATEDIFF function allows to find out the dates difference between the two dates.
I was just wondering if any one knows of a good script to emulate
I was just wondering if any one knew of any good beginner tutorials for
i just wondering is there any performance issue or anything thing wrong if that
Just wondering if there is any way to get the NS records in C#.
Just wondering if there are any pitfalls using .net as the extension for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.