11 November 2024

Windows API - Set the icon of a window created with P/Invoke

This actually turned out to be very easy. Just load the icon as you would in .net.
var icon = new Icon(GetResourceStream("Cards.ico"));

GetResourceStream is a custom method of mine to load the icon file from the embedded resources.

To create the window, you already defined a window class struct somewhere.
var windowClass = new WindowClassEx();
All you have to do, is pass the icon's internal handle to this structure.
windowClass.Icon = icon.Handle;
And make sure the icon object is not destroyed while the window is open.

Windows will look for a small icon for the title bar in Icon when IconSmall is not set.

29 January 2024

GIT - avoid merge-commits

GIT inserts commits named merge branch '{name}' when there was a deviation from the branch. They can be reunited with a rebase command.
git pull --rebase