我知道有多种方法:
SetWindowText
SetWindowTitle可我不知在哪里改比较合适:我想在主窗口标题中不出现子窗口的标题!!!
我在几个地方改了,可子窗口一最大化,标题就变了,
论坛中有文章说在CChildFram的虚函数OnUpdateTitle中修改,可根本没有啊,
那是COle..的虚函数啊!
SetWindowText
SetWindowTitle可我不知在哪里改比较合适:我想在主窗口标题中不出现子窗口的标题!!!
我在几个地方改了,可子窗口一最大化,标题就变了,
论坛中有文章说在CChildFram的虚函数OnUpdateTitle中修改,可根本没有啊,
那是COle..的虚函数啊!
里面
SetTitle("");
是子窗体最大化时,主窗体标题改变了啊,根本不会触发OnNewDocument的!
范例如下:
在CChildFrame的类定义中加入如下函数声明:
class CChildFrame:public CMDIChildWnd
{
...
virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
...
};//OnUpdateFrameTitle的实现
void CChildFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
{
//1-首先调用默认函数
CMDIChildWnd::OnUpdateFrameTitle(bAddToTitle);
//2-现在根据需要调整标题
CString strMyTitle = "MyTitle";
//原有标题
//CString strInitialTitle;
//GetWindowTitle(strInitialTitle);
SetWindowText(strMyTitle);
}
在CChildFrame::PreCreateWindows中加入
cs.style &= ~FWS_ADDTOTITLE;
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE; cs.style &= ~FWS_ADDTOTITLE;
return TRUE;
}BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.style &= ~FWS_ADDTOTITLE;
return TRUE;
}
BOOL CMdiApp::InitInstance()
{
AfxEnableControlContainer();
............ pMainFrame->SetWindowText("Hello");
return TRUE;
}