Why doesn't this work???? HELP!
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
Re: Why doesn't this work???? HELP!
Perhaps are you in the case described by the doc:
"However, SetWindowText cannot change the text of a control in another application."
HTH
K.
Re: Why doesn't this work???? HELP!
use setdlgitemtext instead
Re: Why doesn't this work???? HELP!
Or ::SendMessage(hwnd, WM_SETTEXT, 0L, (LPARAM)(LPCSTR)lpszText)
Rail
------------
Recording Engineer/Software Developer
Rail Jon Rogut Software
http://home.earthlink.net/~railro/
[email protected]
Re: Why doesn't this work???? HELP!
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);
Re: Why doesn't this work???? HELP!