MFC MDI选项卡控件标题更改 [英] MFC MDI tab control caption changing

查看:213
本文介绍了MFC MDI选项卡控件标题更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了没有文档/视图体系结构的应用程序.原因是它不是基于文件的,它主要与数据库有关.大多数情况下,我用于报告.在进一步探讨这个问题之前,我确实在google中寻找解决方案.没有足够的帮助.

当我这样做的时候:
当用户打开报告窗口时,它的顶部有一个基本标题.在用户选择一个客户并请求显示数据后,一堆语句改变了标签栏的标题.到目前为止,这很好.这行得通.代码如下:

I have created my Application without Document/View Architecture. Reason is its not file based, its mostly related with database. Mostly I am using for Reporting. And before I go any further with the question, I did look for the solution in google. Not enough help.

When I did:
when user open a report window it has a basic caption at the top. After user select a Customer and request to display the data, a bunch of statement do the change of the caption of the tab bar. So far this is good. It work. Code is as below:

CWnd *pr=this->GetParent();
pr->SetWindowTextW(ch);



我面临的问题是:
1.当我最小化代码时,标题已更改为初始标题.
2.当我在新标签页中打开一个新窗口时,上一个窗口会立即丢失标题.

一直保持下去的正确方法是什么?

在此先感谢



The problem i am facing is :
1. When I minimize the code Caption got changed to the initial caption.
2. When I open a new window in new tab the previous window lost the caption immediately.

What can be the proper way to keep it all the time?

Thanks in advance

推荐答案

此解决方案仅在您的报表窗口从CFrameWnd派生时适用.

CFrameWndCDocument类的基本窗口标题存储在成员变量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 of CFrameWnd and CDocument classes is stored in the member variable m_strTitle which can be set and retrieved with the virtual functions SetTitle() and GetTitle(). So you should use SetTitle() to change the title or overwrite the function. Note that this will only change the member variable. You must still call SetWindowText(). The member variable is initialized by Create() with the window name passed to Create().

If not using SetTitle(), 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 style FWS_ADDTOTITLE. When this style is set, the title is updated each time when an internal idle flag is set. To remove the flag, overwrite PreCreateWindow() 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);
}


这篇关于MFC MDI选项卡控件标题更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆