Click to See Complete Forum and Search --> : MFC C++


May 11th, 1999, 06:00 AM
Can someone please tell me why is that whenever I use SetWindowText or TextOut in my source code, I get compiler complain of :
"SetWindowTextA is not a member of HWND" and,
"TextOutA is not a member of HWND" ?? Where does the "A" comes from.
I have no such problem if the same function calls are use in the context of the dialog code. Example under MyClass::OnInitDialog() or MyClass::OnOK()

Lothar Haensler
May 11th, 1999, 06:05 AM
take a look at winuser.h

WINUSERAPI
BOOL
WINAPI
SetWindowTextA(
HWND hWnd,
LPCSTR lpString);
WINUSERAPI
BOOL
WINAPI
SetWindowTextW(
HWND hWnd,
LPCWSTR lpString);
#ifdef UNICODE
#define SetWindowText SetWindowTextW
#else
#define SetWindowText SetWindowTextA
#endif // !UNICODE

A is for ANSI, W (wide chars) for Unicode

May 11th, 1999, 06:46 AM
Thanks Lothar,
I have used SetWindowText(pwnd, "Some Text"), of which pwnd was obtained from HWND pwnd = ::FindWindow(MyDialog, NULL)...something like that !!
But the compiler complains anyway. (By the way, I was trying to change the text on a Button)
How can the problem be solved ?

Lothar Haensler
May 11th, 1999, 06:51 AM
if you need to call the API function instead of the class member method, you should use ::SetWindowText instead. Did you try that?