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 / C++ / MFC
  4. CEdit subclass question

CEdit subclass question

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 4 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.
  • N Offline
    N Offline
    nguyenvhn
    wrote on last edited by
    #1

    I created a new class that derived from CEdit. Here is OnChar function: void CMyEdit::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags) { if( nChar>='a' && nChar<='z') { nChar -= 'a'-'A'; } CEdit::OnChar(nChar, nRepCnt, nFlags); } I just wanted to capitalize all typed chars in the edit box. But It seem not to work. Where is the problem? Please, help. Thanks for reading.

    B J R 3 Replies Last reply
    0
    • N nguyenvhn

      I created a new class that derived from CEdit. Here is OnChar function: void CMyEdit::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags) { if( nChar>='a' && nChar<='z') { nChar -= 'a'-'A'; } CEdit::OnChar(nChar, nRepCnt, nFlags); } I just wanted to capitalize all typed chars in the edit box. But It seem not to work. Where is the problem? Please, help. Thanks for reading.

      B Offline
      B Offline
      BlackDice
      wrote on last edited by
      #2

      try using PreTranslateMessage() If I write code in my sleep, does that make me brilliant, or just a lazy programmer? My articles www.stillwaterexpress.com BlackDice - the programmer formerly known as bdiamond

      N 1 Reply Last reply
      0
      • B BlackDice

        try using PreTranslateMessage() If I write code in my sleep, does that make me brilliant, or just a lazy programmer? My articles www.stillwaterexpress.com BlackDice - the programmer formerly known as bdiamond

        N Offline
        N Offline
        nguyenvhn
        wrote on last edited by
        #3

        Thank you. But does anyone explain more why changing nChar in OnChar function did not effect?

        1 Reply Last reply
        0
        • N nguyenvhn

          I created a new class that derived from CEdit. Here is OnChar function: void CMyEdit::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags) { if( nChar>='a' && nChar<='z') { nChar -= 'a'-'A'; } CEdit::OnChar(nChar, nRepCnt, nFlags); } I just wanted to capitalize all typed chars in the edit box. But It seem not to work. Where is the problem? Please, help. Thanks for reading.

          J Offline
          J Offline
          John R Shaw
          wrote on last edited by
          #4

          nguyenvhn wrote: nChar -= 'a'-'A'; First off you might look at an ascii table before you do some thing this strange. Second I am not even going to calculate what value this will result in. If you where going to convert ascii characters in this manner you would have to do the following:

          if( 'a' <= nChar && nChar <= 'z' )
          nChar = 'A' + (nChar - 'a');

          To do it properly you would do the following:

          nChar = toupper(nChar);

          Ok! I lied I (calculated) tried your equation and it worked (mathmaticaly), but don't do it. INTP

          1 Reply Last reply
          0
          • N nguyenvhn

            I created a new class that derived from CEdit. Here is OnChar function: void CMyEdit::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags) { if( nChar>='a' && nChar<='z') { nChar -= 'a'-'A'; } CEdit::OnChar(nChar, nRepCnt, nFlags); } I just wanted to capitalize all typed chars in the edit box. But It seem not to work. Where is the problem? Please, help. Thanks for reading.

            R Offline
            R Offline
            Ravi Bhavnani
            wrote on last edited by
            #5

            Perhaps you could just set the ES_UPPERCASE style? To change the style after the control has been created, use SetWindowLong(). /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

            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