폼이 close되기 전에 폼을 닫을지 말지를 결정하는 CanClose변수를 통해 결정 true면 닫히고, false면 복귀된다.
Application.HandleException(self)는 에러발생메세지 창을 통해 에러를 알린다.
procedure TForm1.Form1CloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if Employees.Active then
try
{ When closing, update the database if connected or save it to disk if not }
if Connection.Connected then
UpdateData else
SaveData;
except
on E: Exception do
begin
Application.HandleException(Self); //에러내용과 함께 에러창이 디스플레이
CanClose := MessageDlg('Data not saved/updated, exit anyway?', //그래도 종료할지 말지 결정
mtConfirmation, mbYesNoCancel, 0) = mrYes;
end;
end;
end;
'델파이' 카테고리의 다른 글
키보드, 마우스 최종입력 알아내기 (0) | 2009.11.07 |
---|---|
[델파이팁]텍스트파일(text file) 읽기 (0) | 2009.10.29 |
[델파이팁]파일복사 copy (0) | 2009.10.29 |
[델파이팁] System.ParamStr(0) 은 Application.ExeName과 같다 (0) | 2009.10.29 |
[델파이팁] 에디트박스에 숫자만 입력되게 (0) | 2009.10.26 |