Daniel's profile picture

Published by

published
updated

Category: Web, HTML, Tech

Accidentally found something nice while working on my gui app (gtk 3.0, C)

Recently ive been working on a new gui app, meant to replace an old text editor i made with wxWidgets. GTK is more flexible and it allows for some really nice customization, you can theme your ui with css which is really cool, plus since gtk is written in c its a great opportunity for me to learn c. Anyway i found something really aesthetically pleasing that might be useful for anyone wanting to make an app look like its from Vista on Windows 11.

Windows 11's window manager automatically rounds the corners of all windows, unless their docked, i think it looks awful design wise so i set out to find a way to make my apps window have sharp corners.

Normal and docked window corners

Fortunately for me Microsoft has some documentation on telling the window manager how to handle a window, which is where i came across the DwmSetWindowAttribute function.

The function takes a handle for the window, the attribute to set, a pointer to the variable containing the attribute and the size of the attribute to set on the pointer of the variable containing the attribute

something like this

DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, &Pref, sizeof(Pref))

To get the window handle of a gtk window, you first have to get it as a gdk window, you also have to include <gdk/gdkwin32.h>, then you call gdk_win32_window_get_handle(gdkWindow) and convert it to HWND

The result should look something like this (excuse the testing label)

Window


So yeah, its not what i wanted to do but it does look nice

To actually make the window not have rounded corners, instead of  DWMWA_NCRENDERING_POLICY use DWMWA_WINDOW_CORNER_PREFERENCE (duh 💀)


2 Kudos

Comments

Displaying 0 of 0 comments ( View all | Add Comment )