Currently viewing: GipsySoft » Front Page» Articles

How do I change the shape of my window in the same way as WinAmp

Changing the window shapes is fairly easy. You basically create a region (HRGN) and then set that region for the window you wish to modify

Here is some sample code that does just that. Add this code to a standard window procedure (WM_CREATE) and you'll see the corners of the window are now rounded

  RECT rc;
  GetWindowRect( hwnd, &rc );
  OffsetRect( &rc, -rc.left, );
  HRGN hrgn = CreateRoundRectRgn( rc.left
        , rc.right
        , rc.bottom
        , 20, 20 );

  SetWindowRgn( hwnd, hrgn, FALSE );


There is normally more to it than this. You'll need to handle the drawing of the window so it looks right and things such as resizing the window can get a little interesting.

It's all possible but it needs a little more work.