Text Box without Dialogs

This is a discussion on Text Box without Dialogs within the Windows Programming forums, part of the Platform Specific Boards category; what if I make a window, and then a TextBox in it, but this time not by creating it in ...

  1. #1
    Former Member
    Join Date
    Oct 2001
    Posts
    955

    Text Box without Dialogs

    what if I make a window, and then a TextBox in it, but this time not by creating it in a Dialog, but creating a child window with the EDIT class. The textbox looks fine, but. how do I get what text does it contain?

    I haven't made a program yet, and I don't micd using C or C++, I just want to know how do you do it.

    Oskilian

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    162
    Use GetDlgItemText(). As the dlg box handle use the parent window's handle. Even though it's not a dlg box it will work.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    When you create the EDIT you specify an ID number as the HMENU param.

    Msg's are sent to the callback of the parent (as specified by the HWNDPARENT param).

    Use hash defines
    ie
    #define IDC_CHILD_EDIT 10001

    Then use IDC_CHILD_EDIT in both the CreateWindow() and WM_COMMAND switch in the parents callback.
    "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

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    that's right, but you don't use GetDlgItemText() becuase you're not using a dialog box.

    just use:

    int GetWindowText(HWND window, LPTSTR buffer, int bufferSize);

    good luck
    U
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    to Urador:

    I think, you may use GetDlgItemText as well, because dialog is a regular window.

    For GetDlgItemText, you specify handle of dialog (as a parent window) and ID of child control.

    For GetWindowText you must provide handle of child control.

    You may choose the method, which is more suitable for you.

  6. #6
    Former Member
    Join Date
    Oct 2001
    Posts
    955
    GetWindowText. that was what I was looking for, thanks!

    I am not planning to do any program with that yet, I was just curious. Thanks!

    Oskilian

  7. #7
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    Golem: Yes, a dialog is a window, but a window isn't necessarily a dialog. Since Oskilian said that he had a window (not a dialog) and that he had created the edit box using CreateWindow() (hence he would have a handle to the window itself) he would be much better off using GetWindowText..... GetDlgItemText in this situation is overkill..


    To my understanding

    GetDlgItemText calls GetDlgItem, and then GetWindowText anyway... so it's also quicker.

    Oskilian: GetWindowText() is exactly what you need
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Obtaining a value from a text box
    By thetinman in forum Windows Programming
    Replies: 1
    Last Post: 11-23-2006, 04:50 PM
  2. Dynamically add statis text to a dialog box
    By earth_angel in forum Windows Programming
    Replies: 8
    Last Post: 06-23-2005, 01:28 PM
  3. Sending text to an edit box
    By ColdFire in forum Windows Programming
    Replies: 1
    Last Post: 09-24-2002, 07:46 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. Getting my text from edit box
    By Marky_Mark in forum Windows Programming
    Replies: 2
    Last Post: 11-16-2001, 12:06 PM

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