请教各位关于"通知消息"的问题!
broom 2005-04-14 11:33:11 我写了一个小程序,用来处理在窗体中的按键消息,程序如下:
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
void __fastcall FormCreate(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
void _fastcall MyMessage(TMessage &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_KEYDOWN,TMessage,MyMessage)
END_MESSAGE_MAP(TForm)
};
//---------------------------------------------------------------------------
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::MyMessage(TMessage &Message)
{
if(this->Caption=="hello")
this->Caption="world";
else
this->Caption="hello";
TForm::Dispatch(&Message);
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
}
//---------------------------------------------------------------------------
现在的问题是,如果我在窗体上添加一个按键,当单击它时,会有一个通知消息BN_CLICKED发生,请问各位老大,怎样用消息映射的方法来处理这个BN_CLICKED消息?