Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Making a EditBox

Making a EditBox

Scheduled Pinned Locked Moved C#
c++questioncsharp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tom Moore
    wrote on last edited by
    #1

    Hi, Ive posted on this board before but in the Visual C++ area. My Question is : In my previous questions, I created a new EditBox Class Called CInitials and changed the OnChar Message to append a '.' after each keypress. The code for that was done like this: void CInitials::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { //** Validate the entered character if (isalpha(nChar) ) { // ** Convert lower to to UPPER case if ( islower(nCHAR) ) nChar -=32; // ** Call the default windows procedure as // ** the value of the nChar may have been altered DefWindowProc(WM_CHAR, nChar, MAKELONG(nRepCnt, nFlags)); // ** Call the default windows procedure // ** again to add the period. nChar = '.'; DefWindowProc(WM_CHAR, nChar, MAKELONG(nRepCnt, nFlags)); } // ** If the backspace key is pressed call the // ** base class function twice to remove the period // ** and the letter if ( nChar == VK_BACK ) { CEdit::OnChar(nChar,nRepCnt,nFlags); CEdit::OnChar(nChar,nRepCnt,nFlags); } } The CInitials Class was derived from the CEdit Class in Visual C++. The question is, can this be done in C#? If yes how? Thanks again ;) Tom

    C 1 Reply Last reply
    0
    • T Tom Moore

      Hi, Ive posted on this board before but in the Visual C++ area. My Question is : In my previous questions, I created a new EditBox Class Called CInitials and changed the OnChar Message to append a '.' after each keypress. The code for that was done like this: void CInitials::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { //** Validate the entered character if (isalpha(nChar) ) { // ** Convert lower to to UPPER case if ( islower(nCHAR) ) nChar -=32; // ** Call the default windows procedure as // ** the value of the nChar may have been altered DefWindowProc(WM_CHAR, nChar, MAKELONG(nRepCnt, nFlags)); // ** Call the default windows procedure // ** again to add the period. nChar = '.'; DefWindowProc(WM_CHAR, nChar, MAKELONG(nRepCnt, nFlags)); } // ** If the backspace key is pressed call the // ** base class function twice to remove the period // ** and the letter if ( nChar == VK_BACK ) { CEdit::OnChar(nChar,nRepCnt,nFlags); CEdit::OnChar(nChar,nRepCnt,nFlags); } } The CInitials Class was derived from the CEdit Class in Visual C++. The question is, can this be done in C#? If yes how? Thanks again ;) Tom

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Pretty much the same way, but instead of the VK enum, you have the Keys enum, so Keys.BackSpace or something like that. The messages are the same ( seeing as it's still a window underneath it all ). Stuff like IsLower is in the Char space, so Char.IsLower(myChar) Christian Graus - Microsoft MVP - C++

      T 1 Reply Last reply
      0
      • C Christian Graus

        Pretty much the same way, but instead of the VK enum, you have the Keys enum, so Keys.BackSpace or something like that. The messages are the same ( seeing as it's still a window underneath it all ). Stuff like IsLower is in the Char space, so Char.IsLower(myChar) Christian Graus - Microsoft MVP - C++

        T Offline
        T Offline
        Tom Moore
        wrote on last edited by
        #3

        Thanks Christian, How do you edit OnChar Messages in a C# EditBox? Tom

        C 1 Reply Last reply
        0
        • T Tom Moore

          Thanks Christian, How do you edit OnChar Messages in a C# EditBox? Tom

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          There's either an OnChar or an OnKeypress, just type public override, and the ide will give you a list to choose from. Christian Graus - Microsoft MVP - C++

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups