如果目标窗口属于当前进程,SetWindowText函数会使WM_SETTEXT消息发送给指定的窗口或控件。然而,如果控件是以WS_CAPTION风格创建的列表框控件,SetWindowText函数将为控件设置文本,而不是为列表项设置文本。
WINUSERAPI //你可以忽视他
UNICODE
BOOL
WINAPI
SetWindowTextA(HWND hWnd,LPCSTR lpString);
WINUSERAPI BOOL WINAPI
SetWindowTextW(HWND hWnd,LPCWSTR lpString);
#ifdef UNICODE //如果定义了UNICODE宏,也就是说如果你使用的是UNICODE编码,则函数调用 \
//SetWindowTextW 否则调用SetWindowTextA
//也就是SetWindowTextW(UNICODE)和SetWindowTextA(ANSI)
#define SetWindowText SetWindowTextW
#else
#define SetWindowText SetWindowTextA
#endif // !UNICODE
MFC友好地封装了它,将他的句柄设置为当前View的句柄
void CWnd::SetWindowText(LPCTSTR lpszString)
{
ASSERT(::IsWindow(m_hWnd));
if (m_pCtrlSite == NULL)
::SetWindowText(m_hWnd, lpszString);
else
m_pCtrlSite->SetWindowText(lpszString);
}