Thread: Win32 Text Field For Input

  1. #1
    Registered User
    Join Date
    Jul 2010

    Question Win32 Text Field For Input

    Hello, I am currently programming a Win32 application and I need a "text field" or a "text box" that the user can type in a number to. I will need a few of these so a example would be great.

  2. #2
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    London, United Kingdom
    Try the windows programming section of the forum.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    .. and moved!
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Jul 2010
    Sorry for posting in the wrong section. I didn't see the Windows programming section..

  5. #5
    train spotter
    Join Date
    Aug 2001
    near a computer
    Use the resource editor to create the Editbox OR use CreateWindowEx() to create one at run time. If you have a lot I suggest the resource editor.

    Read the text with GetDlgItemInt() or GetDlgItemText() and atoi().

    Check some recent threads for code.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  6. #6
    Registered User
    Join Date
    Aug 2010
    New York


    HWND hEdit =CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT",
    put this code in the WM_CREATE part of your WndProc. the code
    above makes a TextBox at x0 and y0 with a width of 100 and a
    height of 20. the SOME_KIND_OF_ID should be defined somewhere
    in your program like this:

    #define SOME_KIND_OF_ID 50
    the WS_HSCROLL and ES_AUTOHSCROLL can be removed (they make
    an horizontal scroll bar). 'hwnd' is the window to put this
    control on. if any questions, ask please.

    Cheers, ComputerWarrior.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Detecting Edit Control Text
    By yoonkwun in forum Windows Programming
    Replies: 2
    Last Post: 07-12-2009, 08:48 AM
  2. DirectX | Drawing text
    By gavra in forum Game Programming
    Replies: 4
    Last Post: 06-08-2009, 12:23 AM
  3. Input a Hex number and output hex number to a text field
    By zoobaby in forum C++ Programming
    Replies: 4
    Last Post: 05-12-2009, 11:26 AM
  4. Replies: 3
    Last Post: 05-25-2005, 01:50 PM
  5. 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