I got a workaround for the bug. I capture the width and height of the form before it is minimized (using SC_MINIMIZE message). Then I set the form width and height after minimizing is finished (using SIZE_MINIMIZED message).
It turns out that the form's width and height gets changed during minimizing to the width and height of wsNormal state. This appeared to happen every 2nd time I minimized.
I tried to make a small demo with the bug, but I couldn't manage to. The bug only appeared when certain controls on my form had their Visible property toggled.