Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 2.51 KB

message-handling-and-mapping.md

File metadata and controls

43 lines (27 loc) · 2.51 KB
description title ms.date helpviewer_keywords ms.assetid
Learn more about: Message Handling and Mapping
Message Handling and Mapping
11/04/2016
MFC, messages
message handling [MFC]
message maps [MFC]
62fe2a1b-944c-449d-a0f0-63c11ee0a3cb

Message Handling and Mapping

This article family describes how messages and commands are processed by the MFC framework and how you connect them to their handler functions.

In traditional programs for Windows, Windows messages are handled in a large switch statement in a window procedure. MFC instead uses message maps to map direct messages to distinct class member functions. Message maps are more efficient than virtual functions for this purpose, and they allow messages to be handled by the most appropriate C++ object — application, document, view, and so on. You can map a single message or a range of messages, command IDs, or control IDs.

WM_COMMAND messages — usually generated by menus, toolbar buttons, or accelerators — also use the message-map mechanism. MFC defines a standard routing of command messages among the application, frame window, view, and Active documents in your program. You can override this routing if you need to.

Message maps also supply a way to update user-interface objects (such as menus and toolbar buttons), enabling or disabling them to suit the current context.

For general information about messages and message queues in Windows, see Messages and Message Queues in the Windows SDK.

What do you want to know more about

See also

Concepts
General MFC Topics
CWnd Class
CCmdTarget Class