C++博客 联系 聚合 管理  

Blog Stats

随笔档案

文章档案

老易的空间

吴展钦

如果目标窗口属于当前进程,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);
}
posted on 2012-04-13 12:53 吴展钦 阅读(1157) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航:   博客园   博客园最新博文   博问   管理