调用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) { int 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 ); } }
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.style &= ~FWS_ADDTOTITLE; // 去除无标题
return TRUE;
}最后,在你需要改变标题的地方(如OnCreate中)SetWindowText("这是我设置的标题");
我已经做好接分的准备了
然后直接调用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)
{
int 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 );
}
}
String Table里将AFX_IDS_APP_TITLE的字符串设置成你所想要的。如"毒龙1000"
这个方法早试过,无效; 2,cs.style &= ~FWS_ADDTOTITLE; // 去除无标题
SetWindowText("这是我设置的标题");
这样只是去掉了"无标题",变成了"***"
cs.style &= ~FWS_ADDTOTITLE; // 去除无标题
SetWindowText(_T("这是我设置的标题"));
好了,谢谢!