 |
|
|
 |
There are currently, 5 guest(s) and 0 member(s) online.
You are an anonymous user. You can register for free by clicking here
|
|
 |
 |
How can I close a MessageBox()
Posted by: Gayle |
|
 |
Topic System API
Closing a Message Box (by Ralph Friedman)
How can I close a MessageBox() (by Ralph Friedman)
You can use a thread to achieve that:  | |  | | unit MsgThread;
interface
uses .linksarray[0]., Messages, SysUtils, Classes, Controls, Forms, StdCtrls, ExtCtrls;
type TMboxThread = class(TThread) private { private declarations } protected procedure Execute; override; public constructor Create; end;
type TFrmMsgThread = class(TForm) BtnClose: TButton; Edit1: TEdit; Edit2: TEdit; Timer1: TTimer; procedure BtnCloseClick(Sender: TObject); procedure Timer1Timer(Sender: TObject); private FFirst: boolean; FMboxThread: TMBoxThread; FWinHandle: HWnd; public { public declarations } end;
var FrmMsgThread: TFrmMsgThread;
implementation
{$R *.DFM}
{ TMboxThread }
constructor TMboxThread.Create; begin FreeOnTerminate := True; inherited Create(False); end;
procedure TMboxThread.Execute; begin { Place thread code here } MessageBox(Application.Handle, 'Text', 'Caption', MB_APPLMODAL + MB_SETFOREGROUND); end;
{ TForm1 }
procedure TFrmMsgThread.BtnCloseClick(Sender: TObject); begin FMBoxThread := TMBoxThread.Create; FFirst := true; Timer1.Enabled := true; end;
procedure TFrmMsgThread.Timer1Timer(Sender: TObject); begin Timer1.Enabled := false; if FFirst then begin FWinHandle := GetForegroundWindow; FFirst := false; Timer1.Enabled := true; end else SendMessage(FWinHandle, WM_CLOSE, 0, 0); end;
end.
|
|
 |
 |
| |
 |
|
|
 |
| Don't have an account yet? You can create one. As a registered user you have some advantages like a theme manager, comments configuration and posting comments with your name. |
|
| "How can I close a MessageBox()" | Login/Create an account | 2 Comments |
|
| | Comments are owned by the poster. We aren't responsible for their content. |
Re: How can I close a MessageBox()(Score: 0) by Anonymous on Feb 26, 2009 - 04:50 AM | | Hi. Explore our blog with top info: graigslist, Face book |
[ Comments not allowed for anonymous users, please register ]
[ Comments not allowed for anonymous users, please register ]
|