본문 바로가기
MFC

CWnd::OnNotify 통지메시지를 처리할 때 사용하는 가상함수

by leo21c 2014. 8. 8.
SMALL

통지메시지(Notify message)는 WM_NOTIFY 윈도우 메시지 파라미터로 전달되는 어떤 코드이며, SendMessage()함수를 이용해 전달되므로 메시지 큐를 거치지 않고 핸들러러 함수에 직접 호출한 결과를 가져옵니다.

이런 통지메시지가 필요한 이유컨트롤 윈도우에 대해 사용자가 발생시킨 각종 이벤트를 부모 윈도우의 코드에서 해결하기 위해서입니다. 만일 통지메시지가 없다면 컨트롤 윈도우의 파생 클래스를 매번 만들어서 사용해야 합니다.

새로운 컨트롤 윈도우를 개발하고자 한다면 통지 메시지에 대해서도 설계해야 합니다. 마치 클래스의 가상 함수를 설계하는 것과 비슷하다고 할 수 있습니다.

(출처: 프리렉 / MFC 윈도우 프로그래밍 406, 407 page)


The framework calls this member function to inform the parent window of a control that an event has occurred in the control or that the control requires some kind of information.

virtual BOOL OnNotify( 
   WPARAM wParam, 
   LPARAM lParam, 
   LRESULT* pResult  
);

Parameters

wParam

Identifies the control that sends the message if the message is from a control. Otherwise, wParam is 0.

lParam

Pointer to a notification message (NMHDR) structure that contains the notification code and additional information. For some notification messages, this parameter points to a larger structure that has the NMHDR structure as its first member.

pResult

Pointer to an LRESULT variable in which to store the result code if the message is handled.

Return Value

An application returns nonzero if it processes this message; otherwise 0.

Remarks

OnNotify processes the message map for control notification.

Override this member function in your derived class to handle the WM_NOTIFY message. An override will not process the message map unless the base classOnNotify is called.

For more information on the WM_NOTIFY message, see Technical Note 61 (TN061), ON_NOTIFY and WM_NOTIFY messages. You may also be interested the related topics described in Control Topics, and TN062, Message Reflection for Windows Controls.

Requirements

Header: afxwin.h


LIST