Hello, I'm working on a Visual C++ 2005 Windows Forms Application using
managed and native code. First of all, I wanted to register my hotkey,
so I did the following:
RegisterHotKey(hWnd,112,NULL,'p');
***hWnd is my form's HWND.
I think this works fine however to test if it really does I want to
capture Windows Messages and check if they are WM_HOTKEY. To do this I
think I need to use IWindowTarget::OnMessage method. Since I didn't
find any documentation about how this can be done in VC++ 2005 I don't
really know how to do so. I tried typing:
bool Windows::Forms::IWindowTarget::OnMessage(Message% m) sealed
{
if (m.Msg == WM_HOTKEY)
{
Application::Exit();
}
}
But this simply doesn't work. I get the following errors:
1> error C3253: 'IMessageFilter.PreFilterMessage' : error with explicit override
1> error C2838: 'IMessageFilter.PreFilterMessage' : illegal qualified name in member declaration
1> error C3648: this explicit override syntax requires /clr:oldSyntax
What does this mean What should I do
With Thanks,
Gal Beniamini.

Registering Hotkey
jeff.adams86
Try this code :-
RegisterHotKey((HWND)Handle.ToPointer(), 1000, 0,
'P');and in WndProc do this :-
virtual void WndProc (Message% m) override
{
if(m.Msg == WM_HOTKEY && HIWORD((DWORD_PTR)m.LParam.ToPointer()) == 'P')
{
Close();
}
Form::WndProc(m);
}
Mark Austin -
Iskander
protected:
void WndProc(Message* m)
{
if (m->Msg == WM_HOTKEY)
{
Application::Exit();
}
}
This compiles fine, just that nothing happens... It's as though the WM_HOTKEY isn't sent. To investigate matters deeper I added a breakpoint to see if any messages arrive, but no. Maybe my hotkey registration is in-correct. Just to know, could you please tell me if this is correct
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
RegisterHotKey(FindWindow(NULL,L"MyForm"), 112, NULL, 'p');
}
***My Form's title is "MyForm".
My intention was that when 'p' was pressed, the application would exit.
With Thanks,
Gal Beniamini.