Menu

#11 F10 gets translated into SC_KEYMENU

open
nobody
None
5
2006-03-23
2006-03-23
Eric Yiskis
No

Had a bug where whenever the Scintilla control had
the focus, and F10 was pressed, it would activate the
File menu. All the other function keys work as you
would expect, you can trap them with the KeyDown
handler.

What seems to be happening is that Scintilla.NET
calles the old-style scintilla.dll. That control
calls DefWndProc which translates an F10 into a
WM_SYSCOMMAND event with SC_KEYMENU as the WParam,
and sends the message directly to the top level
window!(?) Hack! This is why MFC must die!

I tried various ways to intercept the key before
scintilla gets it, (overriding PreProcess Message,
Looking for WM_KEYDOWN in an overriding WndProc
method, etc.) Couldn't get any of those to work.
Finally decided to just redirect the SC_KEYMENU.
Probably a good idea to do this only if Scintilla has
the focus.

[System::Security::Permissions::PermissionSet
(System::Security::Permissions::SecurityAction::Demand
, Name="FullTrust")]
void WndProc(Message* m)
{
if (m->Msg == WM_SYSCOMMAND)
{
if (m->WParam == SC_KEYMENU)
{
Step_Over();
return;
}
}

Form::WndProc(m);
}

Discussion


Log in to post a comment.