Thread: String from a text box

  1. #1
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    String from a text box

    I want to get a string from a text box with GetDlgItmText() (I think this is the function). One of the parameters is the number of characters to get from the textbox. Well, the thing is, I don't know how many characters there are going to be. I just want to get all of the characters from the text box, not a limited amount. And, how would you know once it is the end of the string from a text box? Would there be the esc char ('\0')? Otherwise, how could you tell? Thanks.
    1978 Silver Anniversary Corvette

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    The amount of chars in this function relates to the Maximum. If you set it at 500, and the used types 50. You will be OK.

    The buffer is NULL terminated. The return from this func is an int that tells you the actual amount retreaved

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    There's no other way to get an inexact number of characters? This text box is not going to be a measily 50 chars.
    1978 Silver Anniversary Corvette

  4. #4
    Registered User Esss's Avatar
    Join Date
    Aug 2001
    Posts
    133
    Call GetWindowTextLength() to get the size of the text. Allocate your buffer, then call GetWindowText to retrieve the text.
    Ess
    Like a rat in a maze who says,
    "Watch me choose my own direction"
    Are you under the illusion
    The path is winding your way?
    - Rush

  5. #5
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Thanks, that exactly what I need!
    1978 Silver Anniversary Corvette

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. RicBot
    By John_ in forum C++ Programming
    Replies: 8
    Last Post: 06-13-2006, 06:52 PM
  2. Replies: 4
    Last Post: 03-03-2006, 02:11 AM
  3. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM
  4. Ok, Structs, I need help I am not familiar with them
    By incognito in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2002, 09:45 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM