RichTextBox problem

  • Thread starter Przemyslaw Lopaciuk
  • Start date
P

Przemyslaw Lopaciuk

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
 
G

Guest

Przemyslaw Lopaciuk said:
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.

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;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top