为什么消息死循环退不出来?高手请指教

ThenLong 2003-10-27 07:56:49
unit Unit1;

interface

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

type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure StartMsg();
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
//-------------------------------------------------------------------------
procedure TForm1.StartMsg();
var m:TMsg;
begin
while (true) do
begin
GetMessage(m,Form1.Handle,0,9999);
Application.ProcessMessages;
memo1.Lines.Add(IntToHex(M.wParam,4)+' '+IntToHex(M.lParam,8));
end;
end;

//-------------------------------------------------------------------------

procedure TForm1.Button2Click(Sender: TObject);
begin
//退出
SendMessage(Form1.Handle,WM_CLOSE,0,0);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
//开始循环
StartMsg;
end;

end.
...全文
54 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ThenLong 2003-10-28
  • 打赏
  • 举报
回复
没人啊高手呢?

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧