|
레조님 안녕하세요 오래간만 이네요 ^^
윈도우의 로그오프나 종료 메세지를 잡아 내는 것은 그리 힘들지 않아요
메세지 맵을 작성하시고 메세지를 검사하면 되니까요...
간단하게 코드를 보여 드릴께요 ^^
먼저 헤더
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
void __fastcall WMQueryEndSession(TMessage Msg);
public: // User declarations
__fastcall TForm1(TComponent* Owner);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_QUERYENDSESSION,TMessage,WMQueryEndSession)
END_MESSAGE_MAP(TForm)
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
메인 입니다.
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::WMQueryEndSession(TMessage Msg)
{
if(MessageDlg("정말로 윈도우를 종료할까요?", mtConfirmation, mbOKCancel, 0) == mrOk)
//이부분에서 저장하고 플그램 종료하면 되겠죠 ^^
Msg.Result = true;
else
Msg.Result = false;
}
그럼 즐프하세요 ^^
|