Why does this window have square corners?
On Windows 7 with the Aero theme, Notepad++'s Preferences window has square corners, no system menu icon, a close button, and a darker 1px
border. This window also has an AlwaysOnTop
attribute.
(I resized the window to fit a width of 640px
.)
Interestingly enough, you can copy this style to other windows using AutoHotkey. So, it would seem that there is no dirty tricks involved. However, I don't think I've seen this window style anywhere else.
Is using this style condemned by Microsoft? Does this type of window have a name?
For the curious: Normal vs "Square"
It's called a Tool(bar) Window. Any windows that have the WS_EX_TOOLWINDOW
extended style will be rendered without a system menu or minimize/maximize boxes, and a small titlebar. In Windows XP and up (that support themes), tool windows are usually rendered without rounded corners (at least with the default themes).
This style is usually used for toolbars (Figure 1). You can see it by dragging a toolbar off of a program that lets you rearrange the toolbars. Notice that it becomes a window that looks like the one in question. Windows Explorer also uses it for deskbands (Figure 2) which are basically the same thing. You can see these by dragging a folder to one of the screen edges, then drag the resulting toolbar/deskband out to the desktop.
Obviously some programs use the style for other purposes, often as a way of creating a sort of modal, temporary dialog that is a child to the main program.
Note: this has a couple of effects (the first two of which are usually the reasons for its non-standard usage):
- A window/dialog with this style does not get a button on the taskbar
- It prevents Alt+Tabbing to the dialog
- It also prevents the Alt+PrtScr from capturing just the dialog; the whole parent program window is captured.
Figure 1: MSPaint toolbar window
Figure 2: Windows Explorer deskband
This details the name of this window style and the options available in .NET; see @Synetech's excellent answer for the original purpose of this window style, the reasons it may be used for such a dialog box and the implementation in unmanaged Windows programs such as Notepad++.
The window has square corners and looks like that because one of the designers/programmers of Notepad++ decided to use a specific window style. Synetech details the advantages of that window style.
In .NET/Visual Studio, this is set in the FormBorderStyle
property of the System.Windows.Forms.Form
class. Specifically, it is the FixedToolWindow
. The possible values are in the System.Windows.Forms.FormBorderStyle
enumeration.
The ToolWindow
s in .NET with all values default work a little differently from a plain WS_EX_TOOLWINDOW
in the Windows API, though they look the same. With testing, I have determined that they do appear on the taskbar and they do appear on the Alt+Tab task switcher unless the form property ShowInTaskbar
is set to false
. ShowInTaskbar
affects visibility in both the taskbar and Alt+Tab for ToolWindow
s, but only taskbar for others.
Meanwhile, it is also possible to remove the icon/minimise/restore/maximise buttons from the more common window styles, though it does not seem to be possible to add them to ToolWindow
s. It is also possible to hide normal windows from the taskbar.
The only functional advantage WS_EX_TOOLWINDOW
offers, as far as I can tell, is that the window does not appear in Alt+Tab.
I have included some screenshots comparing the .NET window styles. These are not directly used by Notepad++, nor other unmanaged programs, but are named by Microsoft, so...
Possible values of FormBorderStyle
:
The first image is a screenshot of the running program with Aero enabled, the second is from the Visual Studio designer view (no Aero).
Click the images for the full size versions
Descriptions are taken from the MSDN article on the FormBorderStyle
enumeration.
-
None
No border.
-
FixedSingle
A fixed, single-line border.
-
Fixed3D
A fixed, three-dimensional border.
-
FixedDialog
A thick, fixed dialog-style border.
-
Sizable
(default)A resizable border.
-
FixedToolWindow
A tool window border that is not resizable. A tool window does not appear in the taskbar or in the window that appears when the user presses ALT+TAB. Although forms that specify
FixedToolWindow
typically are not shown in the taskbar, you must also ensure that theShowInTaskbar
property is set tofalse
, since its default value istrue
.
-
SizableToolWindow
A resizable tool window border. A tool window does not appear in the taskbar or in the window that appears when the user presses ALT+TAB.