如何改变窗口标题
2008-10-05 14:49
369 查看
调用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 );
}
}
//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 );
}
}
相关文章推荐
- 如何改变窗口标题(窗口命名)
- 如何改变窗口标题(窗口命名)
- 如何修改MFC对话框的窗口标题
- Win32 : 无标题栏, 可改变大小的窗口
- LaTeX下如何改变章节标题编号的样式?
- c#如何实现无标题栏窗口程序的移动?
- 如何修改MFC单文档的“无标题”、中间的横线、后面的窗口标题
- 在视图类中,如何改变窗口的大小
- win7系统中如何改变半透明窗口的颜色(已使用Aero主题)
- ref C#中的ShowDialog和Show的区别 为什么再ShowDialog中修改变量时原窗口中的变量不会被改变 out如何在这里应用
- 如何让easyui gridview 宽度自适应窗口改变
- 如何修改MFC单文档的“无标题”、中间的横线、后面的窗口标题。
- 如何修改MFC窗口标题
- VC小技巧收集————如何修改窗口标题
- 应用程序各种标题的改变方法 vc多文档应用程序窗口初始化
- C++或者C#中如何拿到一个窗口的标题
- WPF 无标题栏窗口鼠标拖动改变大小
- java 如何让程序窗口随屏幕大小改变
- 单文档接口(SDI)类型窗口标题的改变方法
- 如何修改MFC窗口标题