C
chenliqun
Unregistered / Unconfirmed
GUEST, unregistred user!
假如我开发一个这样的控件,自定义了消息和消息记录,请问怎样在应用这个控件时,
给TClqPaint这个记录赋值,然后发给这个控件使用呢?
unit MyPaint;
interface
uses
SysUtils, Classes, Controls, Windows, Messages;
const
CLQ_PAINT = WM_USER + 1; //定义消息常量标识符
type
TClqPaint = record //消息记录
MsgID : cardinal;
mColor : longint;
mSize : word;
MsgResult: longint;
end;
TMyPaint = class(TCustomControl)
private
{ Private declarations }
procedure Change(var Msg: TClqPaint); message CLQ_PAINT;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('system', [TMyPaint]);
end;
{ TMyPaint }
procedure TMyPaint.Change(var Msg: TClqPaint); //应用。
begin
Size := Msg.mSize;
Color := Msg.mColor;
inherited;
end;
end.
给TClqPaint这个记录赋值,然后发给这个控件使用呢?
unit MyPaint;
interface
uses
SysUtils, Classes, Controls, Windows, Messages;
const
CLQ_PAINT = WM_USER + 1; //定义消息常量标识符
type
TClqPaint = record //消息记录
MsgID : cardinal;
mColor : longint;
mSize : word;
MsgResult: longint;
end;
TMyPaint = class(TCustomControl)
private
{ Private declarations }
procedure Change(var Msg: TClqPaint); message CLQ_PAINT;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('system', [TMyPaint]);
end;
{ TMyPaint }
procedure TMyPaint.Change(var Msg: TClqPaint); //应用。
begin
Size := Msg.mSize;
Color := Msg.mColor;
inherited;
end;
end.