我在VIEW的ONCREATE里用AfxGetMainWnd()->SetWindowText()更改后,但显示不出来。显示的仍然还是默认的 应用程序名+文当名。实在受不了多文当了!!
解决方案 »
- 关于屏蔽复制粘贴发送到等windows菜单的问题
- void CTextureDlg::OnPaint() ,能解释一下吗
- 为什么在CComboBoxEx中无任何显示?
- 我要做一个Web Server,并且要求把网页和图片都做成资源放在程序里面。纯文字的网页好办,图片怎么办?求高手支招!
- 傻傻地问,copyfile函数的用法?
- 寻求libxml2例程
- 菜鸟入门请教 一个基于对话框的工程
- 使用DAO连接ODBC数据源遇到的难题!!!
- 两个问题
- 在Tree Control中怎样得到单击右键时,鼠标指向的Item的标题。谢谢。
- 简单问题,送分!(在线等)
- SQL Server 2000 数据库中的bigint型数据怎么在VC中取出存入__int64啊??
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style &= ~FWS_ADDTOTITLE; // 加上这行
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs return TRUE;
}
virtual void SetTitle( LPCTSTR lpszTitle );ParameterslpszTitlePoints to the string to be used as the document’s title.ResCall this function to specify the document’s title (the string displayed in the title bar of a frame window). Calling this function updates the titles of all frame windows that display the document.CDocument Overview | Class Members | Hierarchy ChartSee Also CDocument::GetTitle
调用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 );
}
}
24、如何防止主框窗口在其说明中显示活动的文档名
创建主框窗口和MDI子窗口进通常具有FWS_ADDTOTITLE风格位, 如果不希望
在说明中自动添加文档名, 必须禁止该风格位, 可以使用ClassWizard重置CWnd: : PreCreateWindow并关闭FWS_ADDTOTITLE风格。
BOOL CMainFrame : : PreCreateWindow (CREATESTRUCT&cs)
{
//Turn off FWS_ADDTOTITLE in main frame .
cs.styel & = ~FWS_ADDTOTITLE ;
return CMDIFrameWnd : : PreCreateWindow (cs );
}
关闭MDI子窗口的FWS _ADDTOTITLE风格将创建一个具有空标题的窗口,可以
调用CWnd: : SetWindowText来设置标题。记住自己设置标题时要遵循接口风格指南。