// *.cpp:
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
UnregisterHotKey(Handle, HotKeyIdentifier_uint); //HotKey löschen
GlobalDeleteAtom(HotKeyIdentifier_uint); //HotKey Identifier löschen
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
HotKeyIdentifier_uint = GlobalAddAtom("RollenTaste");
RegisterHotKey(Handle, HotKeyIdentifier_uint, 0, VK_SCROLL); //Hotkey registrieren.
// statt 0 kann auch MOD_ALT, MOD_CONTROL oder MOD_SHIFT stehen, falls Taste "Rollen" zusammen mit "Shift", "Strg" oder "Alt" gedrückt werden soll
}
//---------------------------------------------------------------------------
void __fastcall TForm1::WMHotKey(TMessage &Msg)
{
TForm::Dispatch(&Msg);
ShowMessage("Rollen Taste gedrückt");
}
// *.h:
class TForm1 : public TForm
{
__published: // Von der IDE verwaltete Komponenten
TLabel *Label1;
void __fastcall FormDestroy(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
private: // Anwender-Deklarationen
void __fastcall WMHotKey(TMessage &Msg);
unsigned int HotKeyIdentifier_uint;
public: // Anwender-Deklarationen
__fastcall TForm1(TComponent* Owner);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_HOTKEY, TMessage, WMHotKey)
END_MESSAGE_MAP(TForm)
};