H
happycyp
Unregistered / Unconfirmed
GUEST, unregistred user!
unit UCMsgThread;
interface
uses
ExtCtrls,Classes,Forms,SysUtils,Dialogs;
type TMsgThread = class(TThread)
private
procedure GetMsg;
protected
published
procedure Execute ;
override;
public
constructor Create(CreateSuspended: Boolean);
destructor Destroy;
override;
end;
implementation
uses USMS, UCHint;
{ TMsgThread }
constructor TMsgThread.Create(CreateSuspended: Boolean);
begin
inherited Create(CreateSuspended);
FreeOnTerminate := true;
end;
destructor TMsgThread.Destroy;
begin
inherited destroy;
end;
procedure TMsgThread.Execute;
begin
inherited;
//Application.ProcessMessages;
//放到线程里没用
while truedo
//循环执行
begin
sleep(200);
GetMsg;
if Terminated then
Break;
end;
end;
procedure TMsgThread.GetMsg;
var
Mobile,CentreNo,CenDate,RcvDate : string;
Order : integer;
bSuc : boolean;
sSuc : string;
begin
if SMS.Busy then
exit;
if SMS.GetMsgStaus(Order,Mobile,CentreNo,CenDate,RcvDate,bSuc) then
begin
if bSuc then
sSuc := '成功。' else
sSuc := '失败。';
ShowMessage('手机:'+Mobile+'收到短信'+#13
+ '短消息中心:'+CentreNO
+ '到达短信中心时间:' + CenDate+ #13
+ '到达对方时间:'+RcvDate+' '+sSuc);
//可以显示对话框。
// sendmessage(yourhandl,WM_user+2001,yourmessage,0);
{ if not Assigned(FrmHint) then
FrmHint := TFrmHint.Create(nil);
FrmHint.LabHint.Caption := ('手机:'+Mobile+'收到短信'+#13
+ '短消息中心:'+CentreNO
+ '到达短信中心时间:' + CenDate+ #13
+ '到达对方时间:'+RcvDate+' '+sSuc);
FrmHint.Top := Screen.Height -30;
FrmHint.Left := Screen.Width - FrmHint.Width;
FrmHint.TM.Enabled := True;
FrmHint.BitBtnLook.Visible := False;
FrmHint.Show;
} //调试发现,执行到这里了,显示不了呀
end;
end;
end.
上面的线程怎么让窗体弹出来呀。
如果用SendMessage发送消息,那么窗体如何接收这个消息。
我的这个线程每0.2s执行一次。请高手指教。
interface
uses
ExtCtrls,Classes,Forms,SysUtils,Dialogs;
type TMsgThread = class(TThread)
private
procedure GetMsg;
protected
published
procedure Execute ;
override;
public
constructor Create(CreateSuspended: Boolean);
destructor Destroy;
override;
end;
implementation
uses USMS, UCHint;
{ TMsgThread }
constructor TMsgThread.Create(CreateSuspended: Boolean);
begin
inherited Create(CreateSuspended);
FreeOnTerminate := true;
end;
destructor TMsgThread.Destroy;
begin
inherited destroy;
end;
procedure TMsgThread.Execute;
begin
inherited;
//Application.ProcessMessages;
//放到线程里没用
while truedo
//循环执行
begin
sleep(200);
GetMsg;
if Terminated then
Break;
end;
end;
procedure TMsgThread.GetMsg;
var
Mobile,CentreNo,CenDate,RcvDate : string;
Order : integer;
bSuc : boolean;
sSuc : string;
begin
if SMS.Busy then
exit;
if SMS.GetMsgStaus(Order,Mobile,CentreNo,CenDate,RcvDate,bSuc) then
begin
if bSuc then
sSuc := '成功。' else
sSuc := '失败。';
ShowMessage('手机:'+Mobile+'收到短信'+#13
+ '短消息中心:'+CentreNO
+ '到达短信中心时间:' + CenDate+ #13
+ '到达对方时间:'+RcvDate+' '+sSuc);
//可以显示对话框。
// sendmessage(yourhandl,WM_user+2001,yourmessage,0);
{ if not Assigned(FrmHint) then
FrmHint := TFrmHint.Create(nil);
FrmHint.LabHint.Caption := ('手机:'+Mobile+'收到短信'+#13
+ '短消息中心:'+CentreNO
+ '到达短信中心时间:' + CenDate+ #13
+ '到达对方时间:'+RcvDate+' '+sSuc);
FrmHint.Top := Screen.Height -30;
FrmHint.Left := Screen.Width - FrmHint.Width;
FrmHint.TM.Enabled := True;
FrmHint.BitBtnLook.Visible := False;
FrmHint.Show;
} //调试发现,执行到这里了,显示不了呀
end;
end;
end.
上面的线程怎么让窗体弹出来呀。
如果用SendMessage发送消息,那么窗体如何接收这个消息。
我的这个线程每0.2s执行一次。请高手指教。