Here is the declaration of a message handler for a user-defined message called CM_CHANGECOLOR.
const CM_CHANGECOLOR = WM_APP + 400; type TMyComponent = class(TControl) . . . protected procedure CMChangeColor(var Message: TMessage); message CM_CHANGECOLOR; end; procedure TMyComponent.CMChangeColor(var Message: TMessage); begin Color := Message.lParam; inherited; end;
#define CM_CHANGECOLOR (WM_APP + 400) class TMyControl : public TControl { protected: void __fastcall CMChangeColor(TMessage &Message); BEGIN_MESSAGE_MAP MESSAGE_HANDLER(CM_CHANGECOLOR, TMessage, CMChangeColor) END_MESSAGE_MAP(TControl) }; void __fastcall TMyControl::CMChangeColor(TMessage &Message) { Color = Message.LParam; // set color from long parameter TControl::CMChangeColor(Message); // call the inherited message handler }
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|