MFC - 当最大化的子窗口具有很长的标题时,MDI 主框架标题被截断 [英] MFC - MDI main frame title is truncated when maximized child window has very long title

查看:32
本文介绍了MFC - 当最大化的子窗口具有很长的标题时,MDI 主框架标题被截断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 MDI 的 MFC 应用程序,类似于 MFC Scribble 示例/教程.当子窗口最大化时,主框架窗口的标题/标题会自动调整,以便附加子窗口的标题,如Scribble - [Scribb1]".当子窗口的标题很长时,它会被截断.整个标题的长度似乎限制在大约 160 个字符.有没有办法增加这个限制并显示更多字符?我想覆盖 WM_NCPAINT 来重绘标题是一种方法,但如果有的话,更喜欢其他简单的解决方案.我试过覆盖 OnUpdateFrameTitle() ,但它似乎不适用于整个组合标题.

I have an MFC application using MDI, something similar to the MFC Scribble example/tutorial. When the child window is maximized, the caption/title of the main frame window is automatically adjusted so that the title of the child window is appended, like "Scribble - [Scribb1]". When the title of the child window is very long, it is truncated. The length of whole caption seems to be limited to about 160 characters. Is there a way to increase this limit and show more characters? I guess overriding WM_NCPAINT to redraw the caption is one way, but prefer other simple solution if there is one. I've tried overriding OnUpdateFrameTitle() and it doesn't seem to work for the whole combined caption.

推荐答案

覆盖 OnUpdateFrameTitle 并调用自己的 UpdateFrameTitleForDocument 实现将不起作用.在发布之前,Amit 已经尝试过您的解决方案.

Overriding OnUpdateFrameTitle and calling own implementation of the UpdateFrameTitleForDocument won’t work. Amit already tried your solution before even posting.

这甚至不是由 MFC 实现的.MDI 窗口不是 MFC 引入的.我记得 MDI 框架窗口是 Windows 操作系统的一部分.

This is not even implemented by MFC. MDI window is not introduced by MFC. MDI frame window existed since I remember as part of the Windows OS.

MFC 内部的默认 MFC 实现会根据需要调用定义为 DefFrameProc 的特殊 MDI 窗口过程.

Default MFC implementation down in the bowels of the MFC calls special MDI window procedure defined as DefFrameProc, as required.

Windows 实现出于某种神秘原因将窗口文本(显示在 MDI 框架的标题栏上)截断为 160 个字符,包括在处理 WM_SETTEXT 消息时终止 0.这可能是没有太多内存可以浪费并且所有缓冲区大小都保持在最低限度的旧计算机的残余.

Windows implementation for some mysterious reason truncate window text (displayed on the title bar of the MDI frame) to 160 characters, including terminating 0 when processing WM_SETTEXT message. This is probably the remnant of the old computers that did not have much memory to waste and all buffers sizes were kept to a minimum.

这可能是没有太多内存可以浪费的旧计算机的残余,所有缓冲区大小都保持在最低限度,文件名总共为 8.3 12 个字符.

This is probably the remnant of the old computers that did not have much memory to waste and all buffers sizes were kept to a minimum and file names were 8.3 total 12 characters.

要满足您的要求并显示全文,您必须进行一些更改.

To fulfill your requirements and display full text you would have to make some changes.

幸运的是,我找到了改变这种行为的非常简单的方法,符合我的 MEMC 要求.

Fortunately, I found really easy way of changing this behavior, in agreement with my MEMC requirement.

在您的主框架类中重写 DefWindowProcand 更改代码如下:

In your main frame class override DefWindowProcand change the code as follows:

LRESULT CMainFrame::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    if(WM_SETTEXT == message)
    {
        // if set text (called from UpdateFrameTitleForDocument)
        // do not call DefWindowProc
        return CWnd::DefWindowProc(message, wParam, lParam);
    }

    // otherwise call DefWindowProc that in turn calls DefFrameProc
    return CMDIFrameWndEx::DefWindowProc(message, wParam, lParam);
}

现在构建并运行.

这适用于 MFC 应用程序的 classinc 和 Visual Studio 样式.

This works for classinc and Visual studio styles of the MFC app.

这篇关于MFC - 当最大化的子窗口具有很长的标题时,MDI 主框架标题被截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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