Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2005

Tip: Looking for answers? Try searching our database.

RichTextBox problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Przemyslaw Lopaciuk - 04 Jun 2005 21:53 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
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;
}

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.