unit Unit2;interfaceuses
Classes,Windows,Messages;type
Comthread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
end;implementationuses unit1;
procedure Comthread.Execute;
begin PostMessage(Form1.Handle,WM_COMMNOTIFY,0,0);
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,unit2, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
Procedure MsgcommProcess(Var Message:Tmessage); Message Wm_commnotify;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;const
Wm_commNotify=Wm_User+12;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
Comthread.Create(false);
end;procedure TForm1.MsgcommProcess(var Message : TMessage);
begin
showmessage('A');
end;
end.
Classes,Windows,Messages;type
Comthread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
end;implementationuses unit1;
procedure Comthread.Execute;
begin PostMessage(Form1.Handle,WM_COMMNOTIFY,0,0);
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,unit2, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
Procedure MsgcommProcess(Var Message:Tmessage); Message Wm_commnotify;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;const
Wm_commNotify=Wm_User+12;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
Comthread.Create(false);
end;procedure TForm1.MsgcommProcess(var Message : TMessage);
begin
showmessage('A');
end;
end.
我昨天还能响应 ,机器重装 吧代码给删了
今天 就响应不了了
我就是想不管主线程的运行情况噶
Classes,Windows,Messages; type
Comthread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
end; implementation uses unit1;
procedure Comthread.Execute;
begin PostMessage(Form1.Handle,WM_COMMNOTIFY,0,0);
end; end.
unit Unit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,unit2, StdCtrls;
const
Wm_commNotify=Wm_User+12; // 提到這裏來。
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
Procedure MsgcommProcess(Var Message:Tmessage); Message Wm_commnotify;
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1;
implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);
begin
Comthread.Create(false);
end; procedure TForm1.MsgcommProcess(var Message : TMessage);
begin
showmessage('A');
end;
end.