Thread: Cleaning all Text fields

  1. #1
    Registered User
    Join Date
    Nov 2004
    Location
    Slovenia, Europe
    Posts
    115

    Cleaning all Text fields

    I'm looking for a function, that would clean all EditText fields in a dialog - something like reset in HTML Forms...

    Thanks for help!

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    I've never heard of such a function, but search MSDN to be sure. Is there a reason you can't just write a function to do this yourself? Why don't you know what text fields there are on a form?

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    There isn't an API function to do this, but the code to implement it is fairly straight forward.

    Code:
    BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
    {
    	char empty = 0;
    	char className[32];
    	GetClassName(hwnd,className,sizeof(className));
    	if(!strcmp(className,"Edit"))
    		SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)&empty);
    	return TRUE;
    }
    
    BOOL ClearDlgEdits(HWND hwndDlg)
    {
    	return EnumChildWindows(hwndDlg,EnumChildProc,0);
    }

  4. #4
    Registered User
    Join Date
    Nov 2004
    Location
    Slovenia, Europe
    Posts
    115
    thanks for code, but i found one different solution:

    SetDlgItemText(hwnd, IDC_TEXT1, "");

    i have to write this for each Edit field, but I have only 4 fields in Dialog.

    Thanks for help anyway!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Text adventure engine idea. thoughts?
    By suzakugaiden in forum Game Programming
    Replies: 16
    Last Post: 01-15-2006, 05:13 AM
  2. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  3. i am not able to figure ot the starting point of this
    By youngashish in forum C++ Programming
    Replies: 7
    Last Post: 10-07-2004, 02:41 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Replies: 1
    Last Post: 07-13-2002, 05:45 PM