更新时间:2022-06-24 14:52:00
此解决方案仅在您的报表窗口从CFrameWnd派生时适用.CFrameWnd
和CDocument
类的基本窗口标题存储在成员变量m_strTitle
中,该成员变量可以使用虚函数SetTitle()
和GetTitle()
进行设置和检索.因此,您应该使用SetTitle()
更改标题或覆盖函数.请注意,这只会更改成员变量.您仍然必须呼叫SetWindowText()
.成员变量由Create()
初始化,并将窗口名称传递给Create()
.
如果不使用SetTitle()
,则屏幕上的标题将使用m_strTitle
文本进行更新.
必须注意的另一点是自动创建框架窗口.由文档模板创建的CFrameWnd
窗口具有隐式样式FWS_ADDTOTITLE
.设置此样式后,每次在设置内部空闲标志时都会更新标题.要删除该标志,请覆盖框架窗口类的PreCreateWindow()
:
This solution applies only when your report windows are derived from CFrameWnd.
The basic window title ofCFrameWnd
andCDocument
classes is stored in the member variablem_strTitle
which can be set and retrieved with the virtual functionsSetTitle()
andGetTitle()
. So you should useSetTitle()
to change the title or overwrite the function. Note that this will only change the member variable. You must still callSetWindowText()
. The member variable is initialized byCreate()
with the window name passed toCreate()
.
If not usingSetTitle()
, the on screen title will be updated using the m_strTitle
text.
Another point that must be observed is the automatic creation of frame windows.CFrameWnd
windows created by document templates have the implicit styleFWS_ADDTOTITLE
. When this style is set, the title is updated each time when an internal idle flag is set. To remove the flag, overwritePreCreateWindow()
of your frame window class:
BOOL CMyFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// Style FWS_ADDTOTITLE is always set when creating a frame window.
// See CDocTemplate::CreateNewFrame() in doctmpl.cpp
cs.style &= ~FWS_ADDTOTITLE;
// Change CFrameWnd to the base class if necessary
return CFrameWnd::PreCreateWindow(cs);
}