Click to See Complete Forum and Search --> : Why doesn't this work???? HELP!


cube01
August 25th, 1999, 02:56 AM
Here's my code:

[ccode]
char strTitle[101];
HWND hWnd = NULL;
HWND hwnd = NULL;



hWnd = ::FindWindow(NULL, "DlgTitle");
hwnd = ::GetDlgItem(hWnd, IDC_EDIT);

::SetWindowText(hwnd, "test");


Everything compiles fine, and it runs fine, except for my edit control doesn't say 'test'
why not?
I've debuged it and all the HWND's get the proper handles, and none of the functions fail...
so what could be the problem?
thank you..
Cube

Karl
August 25th, 1999, 04:30 AM
Perhaps are you in the case described by the doc:
"However, SetWindowText cannot change the text of a control in another application."

HTH

K.

August 25th, 1999, 04:39 AM
use setdlgitemtext instead

Rail Jon Rogut
August 25th, 1999, 04:46 AM
Or ::SendMessage(hwnd, WM_SETTEXT, 0L, (LPARAM)(LPCSTR)lpszText)

Rail

------------
Recording Engineer/Software Developer
Rail Jon Rogut Software
http://home.earthlink.net/~railro/
railro@earthlink.net

David Smulders2
February 19th, 2001, 02:02 PM
This works fine if you want to send a string from CmyListCtrl to CMyListDlg

Make sure that your DlgTitle is correct tipped

//// Sample
#define IDC_EDIT 4321

GetDlgItem(IDC_EDIT)->GetWindowText(m_String);
//// Sample

HWND hWnd = NULL;
HWND hwnd = NULL;



hWnd = ::FindWindow(NULL, "DlgTitle");
hwnd = ::GetDlgItem(hWnd, IDC_EDIT2);

::SetWindowText(hwnd, m_String);

//

or

SetDlgItemText(IDC_EDIT2 , m_String);

link
February 19th, 2001, 02:12 PM
UpdateData(FALSE);