用RegisterHotKey函数,例子
cpp文件:
void __fastcall TForm1::FormCreate(TObject *Sender)
{
RegisterHotKey(this->Handle,1,NULL,VK_MULTIPLY );
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
UnregisterHotKey(this->Handle,1);
}
void __fastcall TForm1::OnHotKey(TMessage &Msg)
{
if(Msg.WParam==1)
{
if(show)
{
ShowWindow(hw,SW_HIDE );
show=false;
}
else
{
ShowWindow(hw,SW_SHOW );
show=true;
}
}
}
hpp文件:
public: // User declarations
__fastcall TForm1(TComponent* Owner);
void __fastcall OnHotKey(TMessage &Msg);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_HOTKEY ,TMessage,OnHotKey)
END_MESSAGE_MAP(TForm)