C++ 窗体最小化时隐藏 (拦截Windows消息示例)

Unit1.h

//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include
#include
#include
#include
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
        BEGIN_MESSAGE_MAP
        MESSAGE_HANDLER(WM_SYSCOMMAND,TMessage,OnWMSysCommand)
        END_MESSAGE_MAP(TForm)
__published: // IDE-managed Components

private: // User declarations

public:  // User declarations

    __fastcall TForm1(TComponent* Owner);

    void __fastcall OnWMSysCommand(TMessage& Message);


};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------

#endif

Unit1.cpp
void __fastcall TForm1::OnWMSysCommand(TMessage& Message)
{
if(Message.WParam==SC_MINIMIZE)
    {
    //MessageBox(NULL,"最小化","最小化",MB_OK|MB_ICONINFORMATION);
    Form1->Hide();
    return;
    }

TForm::Dispatch(&Message);

}

posted on 2005-10-28 16:41  痛并快乐着  阅读(2292)  评论(2编辑  收藏  举报

导航