• 全部
  • 语言基础/算法/系统设计
  • 数据库相关
  • 图形处理/多媒体
  • 网络通信/分布式开发
  • VCL组件开发及应用
  • Windows SDK/API
  • 问答

为什么收不到自己发送的消息?

luxiaoban 2001-09-17 09:21:02
我有正在编写一个控件,

有一个消息需要发送给自己,

但好象自己收不到这个消息,为什么?

BTW:这个控件是继承于TComponent.
...全文
195 点赞 收藏 15
写回复
15 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
luxiaoban 2001-09-17
largewang(垃圾王):

谢谢,成功了
回复
largewang 2001-09-17
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

const wm_me = WM_USER + 1000;

type
TMyComponent = class(TComponent)
private
procedure ReceiveMessage(var Msg: TMessage); message wm_me;
public
function Perform(Msg: Cardinal; WParam, LParam: Longint): Longint;
end;


TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private

{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

{ TMyComponent }

procedure TMyComponent.ReceiveMessage(var Msg: TMessage);
begin
showmessage('afd');
end;

function TMyComponent.Perform(Msg: Cardinal; WParam, LParam: Longint): Longint;
var
Message: TMessage;
begin
Message.Msg := wm_me;//Msg;
Message.WParam := WParam;
Message.LParam := LParam;
Message.Result := 0;
if Self <> nil then Dispatch(Message);
Result := Message.Result;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
M: tmycomponent;
begin
M:= tmycomponent.Create(Self);
try
m.Perform(wm_me,0,0);
finally
m.Free;
end;

end;

end.
回复
luxiaoban 2001-09-17
please answer me.
回复
largewang 2001-09-17
Let me try.
回复
luxiaoban 2001-09-17
I want to know why can not receive message.
回复
gzh5200 2001-09-17
你可以用sendmessage( ),再在wndproc( )中处理消息
回复
largewang 2001-09-17
Why send message to itself?
Use Method, Ok!
another way:
Send message by it`s owner.
回复
title 2001-09-17
帮你推一下!
回复
luxiaoban 2001-09-17
我再推
回复
luxiaoban 2001-09-17
to wantme:

Perform是TControl的函数,我是从TComponent继承的
回复
wantme 2001-09-17
采用Perform函数可以
回复
luxiaoban 2001-09-17
我推
回复
Tense 2001-09-17
hehe
回复
luxiaoban 2001-09-17
自定义消息
回复
发帖
Delphi
创建于2007-08-02

4870

社区成员

Delphi 开发及应用
申请成为版主
帖子事件
创建了帖子
2001-09-17 09:21
社区公告
暂无公告