Application HookMainWindow

weixin_34321977發表於2014-09-01
//H  File
bool
__fastcall AppHookFunc(TMessage &Message);
//cpp file
void __fastcall TForm2::FormCreate(TObject *Sender) { Application->HookMainWindow(this->AppHookFunc); } // --------------------------------------------------------------------------- void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action) { Application->UnhookMainWindow(this->AppHookFunc); } bool __fastcall TForm2::AppHookFunc(TMessage &Message) { bool Handled; switch (Message.Msg) { case WM_CLOSE: mrYes == MessageDlg("Really Close??", mtWarning, TMsgDlgButtons() << mbYes << mbNo, 0) ? Handled = false : Handled = true; break; } return Handled; }

 

相關文章