|
간단한 WM_USER + 1, WM_USER + 2 메시지에 대한 메시지맵 처리 입니다.
아래 헤더 파일에서 메시지를 처리할 함수와 (private 부분) 메시지 맵을
정의합니다.
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
private: // User declarations
void __fastcall TForm1::MessageProcess(TMessage &tmMessage);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_USER + 1, TMessage, MessageProcess);
MESSAGE_HANDLER(WM_USER + 2, TMessage, MessageProcess);
END_MESSAGE_MAP(TForm);
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
실질적인 소스 코드입니다. 함수에서 원하시는 처리를 해주시면 됩니다.
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::MessageProcess(TMessage &tmMessage)
{
ShowMessage("메시지 #" + IntToStr(tmMessage.Msg) + "을 받음");
}
cuperido
이성제 님이 쓰신 글 :
:
|