i want to set the text in the edit control of another window thorugh my program. i retreive the handle of the edit control throgh findwindow and findwindowex and do setwindowtext. but the text is not set.

but if i send the wm_settext message ,the text is set. why?

spy++ shows that the when i call setwindowtext,the caption of the edit control is indeed set to my string. but the text is not displayed. why?

is the caption of edit control different than the text it contains.
Plz Help

Posted on 2003-04-27 12:40:59 by madhur_ahuja
I normally get the handle when I create the object:

invoke CreateWindowEx,WS_EX_CLIENTEDGE,_text,TextCaption,WS_VISIBLE+WS_CHILD,16,180,80,20,[hwnd],107,[hinstance],NULL
mov [txt],eax

Then to set the text to something different:

invoke SendMessage,[txt],WM_SETTEXT,0,_test_title

This code is from fasm, but should be similar with masm.

txt is the object's handle, _test_title is the address of a NULL terminated string.

Hope this helps.
Posted on 2003-04-27 21:13:38 by msmith
Sorry, I didn't notice that you wanted to do this on another window.

The docs say:

The SetWindowText function changes the text of the specified window's title bar (if it has one). If the specified window is a control, the text of the control is changed. However, SetWindowText cannot change the text of a control in another application.

So, what you were trying would not set the text in an edit object.
Posted on 2003-04-27 21:32:39 by msmith

If you get the handle to the edit control in the other application, you can probably set the text for the edit control but be aware that each application has its own memory address space and there are limitation on what can be done across applications that do not share common address space.


Posted on 2003-04-28 01:43:36 by hutch--