Fractal Resurgence
Fractal Resurgence

Reputation: 317

Removing window frame / border properly

I've been working on a custom GUI framework since I just can't deal with managed crap or native code which requires development of UIs through markup (XAML). I am trying to create a prototype of an application which uses that GUI framework, but I am having a platform-specific issue with the nature of windows within WinAPI.

The DWM doesn't really allow customization of the non-client area which breaks immersion, the only thing it allows is extension into the client area in order to give an illusion of customization.

So, the best course of action is to reconstruct the "non-client area" within the client area (relative to WINAPI) and that required me to strip the caption, maximize, minimize buttons etc. So, I basically enumerated all the things I want out and OR-ed them together and flipped all the bits in order to deactivate them.

~(WS_CAPTION | WS_SYSMENU | WS_HSCROLL | WS_VSCROLL | WS_MINIMIZE | WS_MAXIMIZE | WS_THICKFRAME)

Once these style go away, I cannot use normal shutdown procedures (Alt+F4, or right clicking in the taskbar and going "Close") because they don't work. I had to intercept VK_ESCAPE and PostQuitMessage(0) manually just so I could exit without being forced to kill the process.

Why is this so? And how can I fix this?

Upvotes: 3

Views: 2891

Answers (1)

user1309389
user1309389

Reputation:

The short answer

Replace:

~(WS_CAPTION | WS_SYSMENU | WS_HSCROLL | WS_VSCROLL | WS_MINIMIZE | WS_MAXIMIZE | WS_THICKFRAME)

With:

WS_POPUP

And no more funky behavior. The application responds correctly. Enjoy the cake.

The long answer

Ah, as with everything on MSDN lately, the cake is a lie. Window styles are not really just visual. They also specify what inherent window functionalities are available to the application's window(s). Now, there is a fair amount of trickery here to be observed.

First of all, the MSDN isn't really forthcoming and useful with its window style definition table. The default behavior for windows is the classic caption, close, border package which is identified as the WS_OVERLAPPEDWINDOW which occupies the simplest expression, 0 (a 32-bit value, all bits down, 0x00000000), so someone wishing to rush through things could just set 0 for styles in the CreateWindow* function and it would yield a classic window.

What you want is a bare-bone, dirty and empty window. And Microsoft's got exactly the thing you're looking for - WS_POPUP which sets the highest bit to 1 and everything else is 0. This will drop all the fancy resizing automata, window captioning and the cute minimize, maximize and close buttons.

Which means you're going to have to reimplement everything. But that's what you're going for, right?

Just flipping all the bits isn't enough, you will drop the wanted options, but also activate the rest of the options resulting in the application acting funny, what you're experiencing right now. Therefore, you either AND it with something else or use something readily defined by Microsoft - WS_POPUP.

And again. Enjoy the cake and happy coding.

Upvotes: 6

Related Questions