标 题: 如何改变窗口标题
发信人: Pacific (无情~~~Nolove), 信区: VisualC
发信站: BBS 水木清华站 (Fri Oct 16 17:05:29 1998)
调用CWnd : : SetWindowText可以改变任何窗口(包括控件)的标题。
//Set title for application's main frame window .
AfxGetMainWnd ( ) —> SetWindowText (_T("Application title") );
//Set title for View's MDI child frame window .
GetParentFrame ( ) —> SetWindowText ("_T ("MDI Child Frame new title") );
//Set title for dialog's push button control.
GetDigitem (IDC_BUTTON) —> SetWindowText (_T ("Button new title ") );
如果需要经常修改窗口的标题(注:控件也是窗口),应该考虑使用半文档化
的函数AfxSetWindowText。该函数在AFXPRIV.H中说明,在WINUTIL.CPP中实现,在
联机帮助中找不到它,它在AFXPRIV.H中半文档化, 在以后发行的MFC中将文档化。
AfxSetWindowText的实现如下:
voik AFXAPI AfxSetWindowText (HWND hWndCtrl , LPCTSTR IpszNew )
{
itn nNewLen= Istrlen (Ipaznew);
TCHAR szOld [256];
//fast check to see if text really changes (reduces flash in the
controls )
if (nNewLen >_contof (szOld) ||
: : GetWindowText (hWndCrtl , szOld , _countof (szOld) !=nNewLen
||
Istrcmp (szOld , IpszNew )! = 0
{
//change it
: : SetWindowText (hWndCtrl , IpszNew );
}
}
--
老鸟有交待,中鸟要等待,菜鸟要忍耐。
老鸟级功夫:吹牛、聊天、玩MUD 、发呆。
中鸟级功夫:睡觉、灌水、玩游戏、NT&VC。
菜鸟级功夫:学习、泡妞、玩篮球、And so on
My E-Mail: Nolove@263.net
--
☆ 来源:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: yazhou.bbs@bbs.net.t]
※ 修改:.fzx 于 Aug 9 16:50:59 修改本文.[FROM: heart.hit.edu.cn]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.468毫秒