1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- unit UMessageThread;
- interface
- uses
- Classes,Dialogs,SysUtils,Windows;
- procedure MessageOut(ParMessageString,ParMessageCaption:String);
- type
- TMessageThread = class(TThread)
- constructor Create(CreateSuspended:Boolean;
- ParMessageString,ParMessageCaption:String);
- private
- { Private declarations }
- protected
- procedure Execute; override;
- public
- MessageString:String;
- MessageCaption:String;
- end;
- const MaxMessageCount=5;
- var MessageCount:Cardinal=0;
- implementation
- uses Unit1,ShellApi;
- constructor TMessageThread.Create(CreateSuspended:Boolean;
- ParMessageString,ParMessageCaption:String);
- begin
- inherited Create(CreateSuspended);
- MessageString:=ParMessageString;
- MessageCaption:=ParMessageCaption;
- end;
- procedure TMessageThread.Execute;
- begin
- try
- Inc(MessageCount);
- if MessageCount<=MaxMessageCount then
- MessageBox(0, PChar(MessageString),
- PChar(MessageCaption), MB_ICONINFORMATION or MB_OK);
- Dec(MessageCount);
- except
- on e: exception do begin
- showmessage(e.Message);
- end;
- end;
- end;
- procedure MessageOut(ParMessageString,ParMessageCaption:String);
- var MessageThread:TMessageThread;
- begin
- MessageThread:=
- TMessageThread.Create(true,ParMessageString,ParMessageCaption);
- MessageThread.Resume;
- end;
- end.
|