RegisterHotKey with "Windows Forms Application"

R

raym

Hi, I'm trying to figure out how to get a windows forms application I
just made with my visual studio wizard to respond to global hotkeys

I put this code in my Form1.h file:

public:
ATOM nAtom;
Form1(void)
{
InitializeComponent();

nAtom = GlobalAddAtom(L"TypematicHotkey");
UnregisterHotKey((HWND) this->Handle.ToPointer(), this->nAtom);
BOOL bRet = RegisterHotKey((HWND) this->Handle.ToPointer(), nAtom,
MOD_CONTROL, 'A');
bRet = (bRet)|1;
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
UnregisterHotKey((HWND) this->Handle.ToPointer(), this->nAtom);
GlobalDeleteAtom(this->nAtom);
delete components;
}
}

and so far as I can tell it's registering the hotkey, but I don't know
how to do anything once the hotkey is pressed

How do I add an OnHotKey handler, if indeed that's what I'm supposed
to be doing?

Thanks for your time,
- Ray
 
H

Herfried K. Wagner [MVP]

raym said:
Hi, I'm trying to figure out how to get a windows forms application I
just made with my visual studio wizard to respond to global hotkeys

Override the form's 'WndProc' and look for 'WM_HOTKEY' messages.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top