帮我看看我的自定义消息,怎么没有反映啊
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
const WM_SHOW = WM_USER+1024;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
procedure WMSHOW(var MSG:Tmessage); message WM_SHOW;
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
IF KEY=#13 THEN
sendmessage(Hedit,WM_SHOW,0,0);
end;
procedure TForm1.WMSHOW(VAR MSG:Tmessage);
begin
showmessage('系统收到消息');
inherited;
end;
end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
const WM_SHOW = WM_USER+1024;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
procedure WMSHOW(var MSG:Tmessage); message WM_SHOW;
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
IF KEY=#13 THEN
sendmessage(Hedit,WM_SHOW,0,0);
end;
procedure TForm1.WMSHOW(VAR MSG:Tmessage);
begin
showmessage('系统收到消息');
inherited;
end;
end.
解决方案 »
- 98系统下loadLibrary(dll)程序死掉
- 如何关闭pagecontral中的tabsheet
- 使用TNMUDP控件通信时,如何确认另一端已经连接上?谢谢!
- 请问一个关于toolbar和coolbar的用法
- 一个简单的报表问题,在打印时加表格,在线等待!!!!!
- 為什麼我用formatdatetime('yyyy-mm-dd hh:tt:ss',now);保存到數據表中的結果是這個樣子﹕’2002-07-02﹕下午 0‘我設置的字段長度是60﹐
- 如何把word、excel、mp3等二进制格式文件放到SQL Server中,字段类型该怎么设?在线等候!
- 急救!!!~~~~
- 数据编排...急...!送分!
- Comport做的程序在未关串口前拔除USB-UART后关闭程序提示出错
- 新手求助
- dbgrideh的显示问题
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
const WM_SHOW = WM_USER+1024;
type
TForm1 = class(TForm)
Edit1: TEdit;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
procedure WMSHOW(var MSG:Tmessage); message WM_SHOW;
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
sendmessage(application.handle,WM_SHOW,0,0);
end;
procedure TForm1.WMSHOW(VAR MSG:Tmessage);
begin
showmessage('系统收到消息');
end;
end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
procedure WMSHOW(var MSG:Tmessage); message WM_SHOW;
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
Hwindow,Hedit:Thandle;
begin
IF KEY=#13 THEN
begin
Hwindow:=0;
Hedit:=0 ;
Hwindow:=findwindowex(0,Hwindow,'TForm1','Form1');
if Hwindow=0 then exit
else begin
Hedit:=findwindowex(Hwindow,Hedit,'TEdit','Edit2');
sendmessage(Hedit,WM_SETTEXT,0,0);
end;
end;
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;const WM_SHOW = WM_USER+1024;type
TForm1 = class(TForm)
Edit1: TEdit;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
procedure WMSHOW(var MSG:Tmessage); message WM_SHOW;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
sendmessage(handle,WM_SHOW,0,0);//改这里就行了
end;procedure TForm1.WMSHOW(var MSG: Tmessage);
begin
showmessage('系统收到消息');
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;const WM_SHOW = WM_USER+1024;type
TForm1 = class(TForm)
Edit1: TEdit;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
procedure WMSHOW(var MSG:Tmessage); message WM_SHOW;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
sendmessage(handle,WM_SHOW,0,0);//改这里就行了
end;procedure TForm1.WMSHOW(var MSG: Tmessage);
begin
showmessage('系统收到消息');
end;end.
你改的那里Hanldle是什么的句柄啊,我看程序里也没有定义,而且为什么application.Handle不对啊,还有就是我如果想直接给EDIT2发消息,用下面的程序怎么就不可以啊:(
Hwindow:=0;
Hedit:=0 ;
Hwindow:=findwindowex(0,Hwindow,'TForm1','Form1');
if Hwindow=0 then exit
else begin
Hedit:=findwindowex(Hwindow,Hedit,'TEdit','Edit2');
sendmessage(Hedit,WM_SETTEXT,0,0);
Handle应该是Form1的