본문 바로가기
Delphi 문제점 Tip

CooltrayIcon으로 만든 프로그램이 실행중일때 윈도우종료가 안되요? FormCloseQuery(Sender: TObject; var CanClose: Boolean)

by MonoSoft 2022. 4. 27.
728x90
반응형

CooltrayIcon으로 만든 프로그램이 실행중일때 윈도우종료가 안되?

FormCloseQuery(Sender: TObject; var CanClose: Boolean)

 

private

    { Private declarations }

{Detecting Windows Shutdown

To detect Windows Shutdown, you must trap WM_EndSession message. These steps should

be taken: Declare a message handling

procedure in your Form's Private section: }

procedure WMEndSession(var Msg : TWMEndSession); message WM_ENDSESSION;

{Detecting Windows shutdown

When Windows is shutting down, it sends a WM_QueryEndSession to all

open applications. To detect (and prevent shutdown), you must

 

define a message handler to this message. Put this definition on the private section of the main form:}

procedure WMQueryEndSession(var Msg : TWMQueryEndSession); message WM_QueryEndSession;

procedure TFMain.WMEndSession(var Msg: TWMEndSession);

begin

if Msg.EndSession = True then

begin

//

end;

inherited;

end;

 

procedure TFMain.WMQueryEndSession(var Msg: TWMQueryEndSession);

begin

// if MessageDlg('Close Windows ?', mtConfirmation, [mbYes,mbNo], 0) = mrNo then

// Msg.Result := 0

// else

Msg.Result := 1;

end;

 

>> CooltrayIcon으로 만든 프로그램이 실행중일때 윈도우종료가 안되요?

>>

>> procedure TForm1.BtnExiClick(Sender: TObject);

>> begin

>> lClose := True;

>> form1.close;

>> end;

>>

>> procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);

>> begin

>> CanClose := lClose;

>> if not CanClose then

>> begin

>> CoolTrayIcon1.HideMainForm;

>> CoolTrayIcon1.IconVisible := True;

>> end;

>> end;

>>

>> EXIT버튼을 누르면 종료가 되게끔, 이런게 구현을 해놓은 상태입니다.

>> 문제는 프로그램이 실행중일때 "윈도우시스템종료"가 안된다는 것입니다.

>> 고수님들 답변 좀 부탁드립니다~ (__)

 

728x90
반응형

댓글