JohnG
2008-06-25 15:55:33 UTC
Hello
I am inheriting from a TPanel to create a container control
for other panels. I want the user to be able to move the
child panels using the arrow keys. I know that in a form
I can use the following code to accomplish this:
//header file
void __fastcall CMDialogKey(TMessage &Msg);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_DIALOGKEY, TMessage, CMDialogKey)
END_MESSAGE_MAP(TForm)
//source
void __fastcall TForm1::CMDialogKey(TMessage &Msg)
{
switch(Msg.WParam)
{
case VK_LEFT:
case VK_UP:
case VK_RIGHT:
case VK_DOWN:
{
// do something
Msg.Result = false;
break;
}
default: TForm::Dispatch(&Msg);
}
}
However if I try something similar in my TPanel descendant,
the arrow keys are not trapped. Is there any way I can trap the
arrow key for the TPanel descendant directly?
Regards,
JohnG
I am inheriting from a TPanel to create a container control
for other panels. I want the user to be able to move the
child panels using the arrow keys. I know that in a form
I can use the following code to accomplish this:
//header file
void __fastcall CMDialogKey(TMessage &Msg);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_DIALOGKEY, TMessage, CMDialogKey)
END_MESSAGE_MAP(TForm)
//source
void __fastcall TForm1::CMDialogKey(TMessage &Msg)
{
switch(Msg.WParam)
{
case VK_LEFT:
case VK_UP:
case VK_RIGHT:
case VK_DOWN:
{
// do something
Msg.Result = false;
break;
}
default: TForm::Dispatch(&Msg);
}
}
However if I try something similar in my TPanel descendant,
the arrow keys are not trapped. Is there any way I can trap the
arrow key for the TPanel descendant directly?
Regards,
JohnG