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. edit box width

edit box width

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
4 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.
  • R Offline
    R Offline
    Ram Murali
    wrote on last edited by
    #1

    hi all, I would like to set the width of an edit box according to the no of char allowed chars. means-> user can only enter 5 char in the edit box. So i would like to set the width of an edit box which exactly holds 5 chars(no blank space). So how can i draw edit box which holds exactly a specified no of chars? can anyone help in this probs? Thanks in advance. Regards, Ram

    S P N 3 Replies Last reply
    0
    • R Ram Murali

      hi all, I would like to set the width of an edit box according to the no of char allowed chars. means-> user can only enter 5 char in the edit box. So i would like to set the width of an edit box which exactly holds 5 chars(no blank space). So how can i draw edit box which holds exactly a specified no of chars? can anyone help in this probs? Thanks in advance. Regards, Ram

      S Offline
      S Offline
      see me
      wrote on last edited by
      #2

      Try BOOL MoveWindow( int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE ) :) Dream bigger... Do bigger...Expect smaller aji

      1 Reply Last reply
      0
      • R Ram Murali

        hi all, I would like to set the width of an edit box according to the no of char allowed chars. means-> user can only enter 5 char in the edit box. So i would like to set the width of an edit box which exactly holds 5 chars(no blank space). So how can i draw edit box which holds exactly a specified no of chars? can anyone help in this probs? Thanks in advance. Regards, Ram

        P Offline
        P Offline
        Parthi_Appu
        wrote on last edited by
        #3

        You can use SetWindowPos(..), if the editbox can have random string lengths then you have to calculate the size depending on the text selected. if its going to be constant length then decide the size in design time itself. An edit box can have more value than its width, if you want to restrict the string length to some constant value then setting the width won't work out Do your Duty and Don't expect the Result

        1 Reply Last reply
        0
        • R Ram Murali

          hi all, I would like to set the width of an edit box according to the no of char allowed chars. means-> user can only enter 5 char in the edit box. So i would like to set the width of an edit box which exactly holds 5 chars(no blank space). So how can i draw edit box which holds exactly a specified no of chars? can anyone help in this probs? Thanks in advance. Regards, Ram

          N Offline
          N Offline
          Naveen
          wrote on last edited by
          #4

          Ram Murali wrote:

          So i would like to set the width of an edit box which exactly holds 5

          to calculate the rectangle required for a string to fit,use DrawText funtion with the DT_CALCRECT flag. this function will return the rectangle required by the string(Before calling this funtion don't forget to select the current edit box font to the DC). After u got the rectangle call the MoveWindow function to size the edit box. nave

          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