是否可以更改 MDI C# Winforms 中最小化窗口的大小

发布于 2024-10-14 15:58:16 字数 105 浏览 7 评论 0 原文


用户抱怨说,当 MDI 容器中有多个最小化窗口时,除非重新存储每个窗口,否则无法区分它们。我想知道是否可以将最小化窗口变宽一点,以便标题中的文本可以包含 6 个字符?
提前致谢!

Users complain that when they have several minimized windows in MDI container it's impossible to distinguish them unless they resore each. I wonder if it's possible to make minimized window a little bit wider so the text in the caption can contain 6 characters?
Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

葬心 2024-10-21 15:58:16

不,这是不可能的。Windows 使用当前系统参数确定最小化窗口的宽度,并且无法在不更改整个系统的值的情况下为单个应用程序动态更改此宽度。

具体来说,所有最小化窗口的默认大小都是 160x31。在 MDI 应用程序中,您实际上可以看到此大小,因为窗口被最小化到其 MDI 主机中,而不是 Windows 任务栏中。 Raymond Chen(微软 Windows Shell 团队的开发人员)不久前发表了几篇博客文章,解释了为什么选择这个特定的大小,以及它的含义。第一个可以在这里找到: 为什么最小化的窗口有一个明显的大小为 160x31? 第二个后续条目可以在此处阅读:不,真的,为什么是 160x31? 正如他在第二篇文章中解释的那样:

微型标题栏的宽度由MINIMIZEDMETRICS 结构的iWidth 成员确定。您可以借助 SystemParametersInfo 函数检索和更改此结构。 (分别使用 SPI_GETMINIMIZEDMETRICSSPI_SETMINIMIZEDMETRICS 标志。)有些人会提到 MinWidth 注册表值,但那些人错了。例如,请注意,弄乱 MinWidth 需要一个注销周期,而使用 SPI_SETMINIMIZEDMETRICS 会立即生效。这是因为 SPI_SETMINIMIZEDMETRICS 会更新内部状态变量,而修改注册表只会更改数据库中的一个值,一旦您登录,就没有人会注意到该值。

身高呢?这只是标题栏的高度,您可以从“显示”控制面板的“外观”选项卡进行调整。 (通过编程方式,您可以使用有用的 SystemParametersInfo 函数,这次使用 NONCLIENTMETRICS 结构的 iCaptionHeight 成员。)

因为我怀疑您的用户是否真的希望您通过 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:

The width of the miniature title bar is determined by the iWidth member of MINIMIZEDMETRICS structure. You can retrieve and change this structure with the help of the SystemParametersInfo function. (Use the SPI_GETMINIMIZEDMETRICS and SPI_SETMINIMIZEDMETRICS flags, respectively.) Some people will mention the MinWidth registry value, but those people are wrong. Notice, for example, that messing with MinWidth requires a logoff cycle, whereas using SPI_SETMINIMIZEDMETRICS takes effect immediately. That's because SPI_SETMINIMIZEDMETRICS updates the internal state variables, whereas whacking the registry just change a value in a database that nobody pays attention to once you've logged on.

What about the height? That's just the height of a caption bar, which you can adjust from the Appearance tab of the Display control panel. (Programmatically, you can use that helpful SystemParametersInfo function, this time using the iCaptionHeight member of the NONCLIENTMETRICS structure.)

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.

网名女生简单气质 2024-10-21 15:58:16

[虽然这篇文章已有 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

牛↙奶布丁 2024-10-21 15:58:16

对于那些和我有同样问题的人,我找到了解决方案:

(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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文