Prod.: Engine, ver.: 6, ID: 60001387, HowTo : How can I make command's line textbox to accept spacebar as enter

HowTo : How can I make command's line textbox to accept spacebar as enter

Article60001387
TypeHowTo
ProductEngine
Version6
Date Added5/4/2011
Submitted byPeter Chanios
Keywords

Subject

How can I make command's line textbox to accept spacebar as enter

Summary

I want to make the commandline to behave the same when I press enter and when I press spacebar.

Solution

You should use the Command's line userText box event KeyDown and send an enter message to it when the space is pressed like in the code below :

void UserText_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
VectorDraw.WinMessages.MessageManager.MSG m = new VectorDraw.WinMessages.MessageManager.MSG();
m.hwnd = vdFramedControl1.CommandLine.UserText.Handle;
m.lParam = IntPtr.Zero;
m.message = (int)VectorDraw.WinMessages.MessageManager.Messages.WM_KEYDOWN;
m.wParam = (IntPtr)Keys.Enter;

VectorDraw.WinMessages.MessageManager.TranslateMessage(ref m);
VectorDraw.WinMessages.MessageManager.DispatchMessage(ref m);
}
}

private void Form1_Load(object sender, EventArgs e)
{
vdFramedControl1.CommandLine.UserText.KeyDown += new KeyEventHandler(UserText_KeyDown);
}