Thread: edit boxes

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001

    edit boxes

    is there anyway to just completely clear every edit box ina window? And is there any way for the prog to write stuff in edit boxes after the user does something?

  2. #2
    the Corvetter
    Join Date
    Sep 2001
    >> And is there any way for the prog to write stuff in edit boxes after the user does something? <<

    Just send a message I believe with the message being EM_SETTEXT (maybe this, but something like this). I'll look for the reference. I'm not sure if that's the constant. I just...blanked out

    1978 Silver Anniversary Corvette

  3. #3
    Join Date
    Jan 2002
    If you know in advance the handles of the edits then sending a WM_SETTEXT msg with appropriate params will work (SetDlgItemText does the same thing, SetWindowText too) to set the text to anything you want, including clearing all text. To respond to user input you must trap the EN_CHANGE msg within the parent's WM_COMMAND handler.

    If you don't know in advance what the edit handles are, or if there are a variety of cntrls then you might want to consider using EnumChildWindows. You will have to define a callback fn which is called for each child cntrl. The callback will be sent the handle of each child wnd in turn so you can use GetClassName on that handle to see whether it is "EDIT". Return FALSE from the callback fn to signal you are finished.
    const int NUM_EDITS=10; //eg you have 10 edit cntrls
    int nNumEditCntrls=NUM_EDITS;
    BOOL CALLBACK MyEnumChildProc(HWND hwnd,LPARAM lParam)
    if (!lstrcmp(CharUpper(GetClassName(hwnd)),TEXT("EDIT")))
        //cntrl is EDIT so clear it
        if (!nNumEditCntrls)
            return FALSE;   //no more edits
    return TRUE;    //keep enumerating child wnd's
    //To call the EnumChildProc:
    Hope that is of some use to you.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_HSCROLL in ES_READONLY edit box error
    By Homunculus in forum Windows Programming
    Replies: 4
    Last Post: 02-13-2006, 08:46 AM
  2. Edit box(es), and specialized onmouseover
    By Lurker in forum Windows Programming
    Replies: 7
    Last Post: 05-25-2003, 04:13 PM
  3. Edit Boxes
    By ColdFire in forum Windows Programming
    Replies: 2
    Last Post: 02-13-2002, 02:54 PM
  4. please help visual c++ edit control boxes
    By alcoholic in forum C++ Programming
    Replies: 3
    Last Post: 02-05-2002, 02:39 PM
  5. Password Edit Boxes
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 08-27-2001, 02:40 PM