F
foreveryouth
Unregistered / Unconfirmed
GUEST, unregistred user!
我的自定义组件里有一个button按钮,单击它时,想给自定义组件发送一个
自定义消息CM_SearchReady,而自定义组件的处理事件OnSearchReady设成published,
这样在窗体中加入这个自定义组件时,可将这个自定义消息发给窗体,让窗体处理这个
消息。
这样写问题在哪儿?窗体不能接受到这个消息。我刚刚学组件开发,很多地方不懂,别见笑!
const CM_SearchReady=WM_USER + 999;
type
TCM_SearchReady=record
msgid:cardinal;
msize:word;
mcolor:longint;
msgresult:longint;
end;
type
TCustomPanel1 = class(TCustomPanel)
cedit_jiansuoshi:TEdit;
procedure cbitbtn_jiansuoClick(Sender: TObject);
private
{ Private declarations }
cbitbtn_jiansuo:TBitBtn;
FOnSearchReady: TNotifyEvent;
procedure CMSearchReady(var Message: TMessage); message CM_SearchReady;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner:TComponent);override;
published
{ Published declarations }
property Align;
property OnSearchReady: TNotifyEvent read FOnSearchReady write FOnSearchReady;
end;
implementation
//***********初始化控件***********************************
constructor TCustomPanel1.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
cbitbtn_jiansuo:=TBitBtn.Create(self);
cbitbtn_jiansuo.parent:=self;
cbitbtn_jiansuo.caption:='检索';
cbitbtn_jiansunClick:=cbitbtn_jiansuoClick;
cbitbtn_jiansuo.Show ;
end;
procedure TCustomPanel1.cbitbtn_jiansuoClick(Sender: TObject);
var
szMsgStr:array[0..255] of char;
begin
SendMessage(parent.handle,CM_SearchReady,Integer(@szMsgStr),0);
end;
procedure TCustomPanel1.CMSearchReady(var Message: TMessage);
begin
inherited;
end;
end.
在form中加入这个组件与一个edit控件
procedure TForm1.CustomPanel11SearchReady(Sender: TObject);
begin
Edit1.Text:='aa';
end;
可没反应,请高手指教!!!
自定义消息CM_SearchReady,而自定义组件的处理事件OnSearchReady设成published,
这样在窗体中加入这个自定义组件时,可将这个自定义消息发给窗体,让窗体处理这个
消息。
这样写问题在哪儿?窗体不能接受到这个消息。我刚刚学组件开发,很多地方不懂,别见笑!
const CM_SearchReady=WM_USER + 999;
type
TCM_SearchReady=record
msgid:cardinal;
msize:word;
mcolor:longint;
msgresult:longint;
end;
type
TCustomPanel1 = class(TCustomPanel)
cedit_jiansuoshi:TEdit;
procedure cbitbtn_jiansuoClick(Sender: TObject);
private
{ Private declarations }
cbitbtn_jiansuo:TBitBtn;
FOnSearchReady: TNotifyEvent;
procedure CMSearchReady(var Message: TMessage); message CM_SearchReady;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner:TComponent);override;
published
{ Published declarations }
property Align;
property OnSearchReady: TNotifyEvent read FOnSearchReady write FOnSearchReady;
end;
implementation
//***********初始化控件***********************************
constructor TCustomPanel1.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
cbitbtn_jiansuo:=TBitBtn.Create(self);
cbitbtn_jiansuo.parent:=self;
cbitbtn_jiansuo.caption:='检索';
cbitbtn_jiansunClick:=cbitbtn_jiansuoClick;
cbitbtn_jiansuo.Show ;
end;
procedure TCustomPanel1.cbitbtn_jiansuoClick(Sender: TObject);
var
szMsgStr:array[0..255] of char;
begin
SendMessage(parent.handle,CM_SearchReady,Integer(@szMsgStr),0);
end;
procedure TCustomPanel1.CMSearchReady(var Message: TMessage);
begin
inherited;
end;
end.
在form中加入这个组件与一个edit控件
procedure TForm1.CustomPanel11SearchReady(Sender: TObject);
begin
Edit1.Text:='aa';
end;
可没反应,请高手指教!!!