5

I'd like to create a Form without title bar while keeping the border so I can still resize and snap it. Setting FormBorderStyle to None would work, but it destroys the border.

After searching Google for a bit, I encountered a method quite a few times, also here: Setting ControlBox to False as well as Text to an empty string seems to have worked on older versions of Windows, on Windows 10 however it looks like this:

Ugly rest of title bar

Note the ugly bar at the top, which I would like to get rid of. Every other solution I found - e.g. overriding WndProc - either simply did not work, or removed the border as well.

Edit: The white bar is in non-client area, it's what's left over from the title bar after removing the window buttons and title text.

Benni
  • 778
  • 8
  • 22
  • Can confirm that. Ugly white non-client bar on top. It's acting as a border, to resize the height, why is it so big? Must be a bug. – Sinatr Jan 02 '19 at 16:00
  • 1
    Would you mind to try [this hack](https://superuser.com/a/961865/547545), perhaps it's mentioned `PaddedBorderWidth`. – Sinatr Jan 02 '19 at 16:02
  • On this question https://stackoverflow.com/questions/2575216/how-to-move-and-resize-a-form-without-a-border the second answer by user1306322 uses `FormBorderStyle=None` but draws the border back on and handles the necessary events to allow it to be resizable. – steve16351 Jan 02 '19 at 16:18
  • @Sinatr As far as I can tell, this modifies the registry, which is a global approach to this problem. However, I'd like my application to work on any Windows machine, without having to change the registry. – Benni Jan 02 '19 at 17:35
  • @steve16351 I've already stumbled across that answer, but my application still does not support resizing or snapping after using the code. – Benni Jan 02 '19 at 17:40
  • [Prevent Win32 from drawing classic title bar](https://stackoverflow.com/questions/46776425/prevent-win32-from-drawing-classic-title-bar). Not a *final* answer, but you can work with it. See the Docs [DwmExtendFrameIntoClientArea](https://learn.microsoft.com/en-us/windows/desktop/api/dwmapi/nf-dwmapi-dwmextendframeintoclientarea) and [DwmSetWindowAttribute](https://learn.microsoft.com/en-us/windows/desktop/api/dwmapi/nf-dwmapi-dwmsetwindowattribute). You can find most of the declaration [here](https://stackoverflow.com/a/51580871/7444103). – Jimi Jan 02 '19 at 18:33
  • See also: [Custom Window Frame Using DWM](https://learn.microsoft.com/en-us/windows/desktop/dwm/customframe) and this CodeProject: [Fancy Windows Forms](https://www.codeproject.com/articles/33716/fancy-windows-forms?fid=1536616&df=90&mpp=25&sort=Position&view=Normal&spc=Relaxed&fr=101). Different paths. – Jimi Jan 02 '19 at 19:02
  • Benni did you found a way to solve the problema with the ugly bar at top? – Xam Jul 05 '19 at 18:18
  • 1
    @Xam unfortunately, I did not :( – Benni Jul 22 '19 at 17:45

0 Answers0