Win32 Text Field For Input

This is a discussion on Win32 Text Field For Input within the Windows Programming forums, part of the Platform Specific Boards category; Hello, I am currently programming a Win32 application and I need a "text field" or a "text box" that the ...

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    3

    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
    Location
    London, United Kingdom
    Posts
    2,094
    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
    Location
    Singapore
    Posts
    21,445
    .. and moved!
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

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

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    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
    Location
    New York
    Posts
    11

    Smile

    Code:
    HWND hEdit =CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT",
    "Type Text Here",WS_CHILD|WS_VISIBLE|WS_HSCROLL|ES_AUTOHSCROLL,
    0,0,100,20,hwnd,(HMENU)SOME_KIND_OF_ID,GetModuleHandle(NULL),
    NULL);
    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:

    Code:
    #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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21