I want to make RichTextBox very similar to Windows Command Prompt (cmd.exe).
It means that I need that nobody can delete the prompt and move cursor in
window except in the same line.
I use the following code:
if (e->KeyCode == Keys::Enter && connection == NULL ){
NetPromptBox->SelectAll();
NetPromptBox->SelectionProtected = false;
NetPromptBox->Text =
String::Concat(NetPromptBox->Text,S"\r\nSERVER>> ");
NetPromptBox->SelectAll();
NetPromptBox->SelectionProtected = true;
NetPromptBox->SelectionLength = 0;
NetPromptBox->SelectionStart = NetPromptBox->TextLength+1;
}
The problem is that user can still go up and down in window and the cursor
after you press ENTER is not in the same line as SERVER>> but in next one.
Could anybody help me please?
Thank you,
Przemyslaw Lopaciuk
JHoletzeck - 07 Jun 2005 11:57 GMT
> I want to make RichTextBox very similar to Windows Command Prompt (cmd.exe).
> It means that I need that nobody can delete the prompt and move cursor in
[quoted text clipped - 14 lines]
> The problem is that user can still go up and down in window and the cursor
> after you press ENTER is not in the same line as SERVER>> but in next one.
Have a look at ENM_KEYEVENTS (see sample code below)...
void SomeClass::OnMsgfilterMainwin(NMHDR* pNMHDR, LRESULT* pResult)
{
MSGFILTER *pMsgFilter = reinterpret_cast<MSGFILTER *>(pNMHDR);
// TODO: The control will not send this notification unless you override the
// CDialog::OnInitDialog() function to send the EM_SETEVENTMASK message
// to the control with either the ENM_KEYEVENTS or ENM_MOUSEEVENTS flag
// ORed into the lParam mask.
// TODO: Add your control notification handler code here
switch(pMsgFilter->msg)
{
case WM_RBUTTONDOWN:
{
// do something
break;
}
case WM_CHAR:
{
switch(pMsgFilter->wParam)
{
case 0x16: // CTRL+v
{
// do something
break;
}
}
*pResult = 0;
}