Can not catch KeyDown message from RETURN key

  • Thread starter Thread starter Roman Muntyanu
  • Start date Start date
R

Roman Muntyanu

Hi all,

I got a problem with Return key in my C++/C# application.
On CView dilalog I put my C# control. This C# control has couple
other controls nested. I have problem with RichTextBox control which
is at the bottom of my control hierarchy. It does not process
VK_RETURN key down. So I can not create new line. All other keys work
in RichTextBox. Of course I made it Multiline. I used Spy++ tool to
figure out what is going on. I managed to see that RichTextBox window
receives RETURN message. But nothing happens.
My OnKeyDown handler is hit for all keys except of RETURN.

I would greatly appreciate any hints.

Thanks in advance,
Roman
 
Roman,

Can you provide a sample in the zip file, demonstrating your problem?. I
will investigate on that and hopefully it can be fixed.
 
Hi Shak,

I tried to send zip file with my testing project to (e-mail address removed)
but delivery failed. Is this possible to post file in this thread?
Or mayby I can send to another your address.

I appreciate your time.

Thanks, Roman
 
Roman.,

We both had good email communication, and finally got the solution for your
problem. I am posting the answer for others to benefit

To In the derived class of RichEditBox,

protected override void WndProc(ref Message m)
{
int WM_GETDLGCODE = 0x0087;
int VK_RETURN = 0x0D;
if (m.Msg == WM_GETDLGCODE)
{
if (m.WParam.ToInt32() == VK_RETURN)
{
base.SelectedText = "\n";
return ;
}
}
base.WndProc (ref m);
}
 
Back
Top