是否可以更改 MDI C# Winforms 中最小化窗口的大小
用户抱怨说,当 MDI 容器中有多个最小化窗口时,除非重新存储每个窗口,否则无法区分它们。我想知道是否可以将最小化窗口变宽一点,以便标题中的文本可以包含 6 个字符?
提前致谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
用户抱怨说,当 MDI 容器中有多个最小化窗口时,除非重新存储每个窗口,否则无法区分它们。我想知道是否可以将最小化窗口变宽一点,以便标题中的文本可以包含 6 个字符?
提前致谢!
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
不,这是不可能的。Windows 使用当前系统参数确定最小化窗口的宽度,并且无法在不更改整个系统的值的情况下为单个应用程序动态更改此宽度。
具体来说,所有最小化窗口的默认大小都是 160x31。在 MDI 应用程序中,您实际上可以看到此大小,因为窗口被最小化到其 MDI 主机中,而不是 Windows 任务栏中。 Raymond Chen(微软 Windows Shell 团队的开发人员)不久前发表了几篇博客文章,解释了为什么选择这个特定的大小,以及它的含义。第一个可以在这里找到: 为什么最小化的窗口有一个明显的大小为 160x31? 第二个后续条目可以在此处阅读:不,真的,为什么是 160x31? 正如他在第二篇文章中解释的那样:
因为我怀疑您的用户是否真的希望您通过 P/Invoking 来弄乱他们的默认系统参数
SystemParametersInfo
函数,您没有留下太多选项。我的建议是切换到替代界面,特别是如果他们一次使用一个窗口并最小化其他窗口。 MDI 的目的是允许用户平铺或级联多个窗口,以便他们一次可以看到多个窗口。由于听起来这不是典型的用例,因此通过将应用程序切换为使用选项卡可能会为您提供更好的服务。这通常称为选项卡式文档界面(TDI),是旧的多文档界面(MDI) 的更现代的实现。这些年来它变得非常流行;查看维基百科文章。No, this is not possible. Windows determines the width of a minimized window using the current system parameters, and there's no way to change this dynamically for a single application without changing the values across the entire system.
Specifically, the default size of all minimized windows is 160x31. In a MDI application, you actually get to see this size because the window is minimized into its MDI host, rather than into the Windows taskbar. Raymond Chen (a developer on the Windows Shell team at Microsoft) published a couple of blog entries a while back that explain why this particular size was chosen, and what it means. The first is available here: Why do minimized windows have an apparent size of 160x31? And the second follow-up entry can be read here: No, really, why is it 160x31? As he explains in that second post:
Since I doubt your users really want you messing with their default system parameters by P/Invoking the
SystemParametersInfo
function, you aren't left with a whole lot of options. My recommendation, especially if they're working with a single window at a time and leaving the others minimized, is to switch to an alternative interface. The intention of MDI was to allow users to tile or cascade multiple windows so that they could see more than one at a time. Since it sounds like that's not the typical use case, you might both be better served by switching the application to use tabs instead. This is often called a tabbed document interface (TDI), a somewhat more modern implementation of the old multiple document interface (MDI). It's become quite popular over the years; check out the Wikipedia article.[虽然这篇文章已有 11 年历史,但我正在努力......:
我遇到了应用程序内最小化窗口的问题,该问题在我的 Windows11 上被破坏了(当然是由某个软件造成的,但我不知道是哪个......)。这些应用程序内最小化的窗口比应有的要窄得多。我只能看到关闭按钮,而不是包含标题和 3 个按钮的最小化标题栏。您在这里说不可能为独特的软件更改此大小,但我假设您知道在哪里更改整个系统的大小?以下是 ultraedit 1 中的问题捕获,以及 3dsMax 中的问题 2
[Although this post is 11 years old, i'm trying...:
I'm facing an issue with in-app minimized windows, which are broken on my Windows11 (certainly by a software, but I don't know which one...). Those in-app minimized windows are much more narrower that it should be. Instead of having the minimized title bar containing title and 3 buttons, I can only see the close button. You said here it wasn't possible to change this size for a unique software, but I assume you know(knew) where to change it for the whole system? Here is a capture of the issue in ultraedit 1 and here in 3dsMax for example 2
对于那些和我有同样问题的人,我找到了解决方案:
(win+r) regedit
HKEY_CURRENT_USER\控制面板\桌面\WindowMetrics
添加字符串值“MinWidth”。
更改名为“MinWidth”的字符串值。使用以下公式设置其值:
-15*宽度(以像素为单位)
对我来说,可接受的宽度是 -3300
小缺点:它还会更改任务栏中最小化窗口的大小(当任务栏中有几个窗口时,使它们更宽)
To those who have the same problem as me, I found the solution:
(win+r) regedit
HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics
add the string value "MinWidth".
Change the string value named "MinWidth". Set its value using the following formula:
-15*width in pixels
For me, acceptable one was -3300
Little drawback: It also changes size of the minimized windows in the taskbar (make them much wider when there is a few of them in taskbar)