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!
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 ofMINIMIZEDMETRICS
structure. You can retrieve and change this structure with the help of theSystemParametersInfo
function. (Use theSPI_GETMINIMIZEDMETRICS
andSPI_SETMINIMIZEDMETRICS
flags, respectively.) Some people will mention theMinWidth
registry value, but those people are wrong. Notice, for example, that messing withMinWidth
requires a logoff cycle, whereas usingSPI_SETMINIMIZEDMETRICS
takes effect immediately. That's becauseSPI_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 theiCaptionHeight
member of theNONCLIENTMETRICS
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.
来源:https://stackoverflow.com/questions/4813637/is-it-possible-to-change-size-of-minimized-window-in-mdi-c-sharp-winforms