반응형
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Interval := 2000;
Timer1.Enabled := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage('http://www.howto.pe.kr');
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
XForm: TForm;
begin
Timer1.Enabled := False;
Timer1.Enabled := True;
XForm := Screen.ActiveForm;
// 이미 뜬 다이얼로그 박스가 없으면 띄운다
if not Assigned(XForm) or (XForm.ClassName <> 'TMessageForm') then
MessageDlg('타이머에서 뜬 폼입니다', mtInformation, [mbOK], 0)
// 이미 뜬 폼을 닫는다
else if XForm.ClassName = 'TMessageForm' then
XForm.Close;
end;
end.
반응형