How can I toggle my titlebar on and off?

Basically, move frame window controls from being children of the frame to being children of the background HWND_OBJECT. You can then reverse the process to bring them back into view. Following function implements this code.

/* --------------------------------------------------------------
-- Function:  ToggleFrame
--
-- Description:  Toggles frame control visible/invisible
--
-- Notes: Code stolen from someone who stole it from an MS sample
----------------------------------------------------------------- */
void ToggleFrame(HWND hwndFrame) {

 if (! Hidden) {     /* hide contorls */
    hwndTitle = WinWindowFromID( hwndFrame, FID_TITLEBAR );
    hwndSys   = WinWindowFromID( hwndFrame, FID_SYSMENU );
        ... repeat for FID_MINMAX, etc ...
    WinSetParent(hwndTitle, HWND_OBJECT, FALSE );
    WinSetParent(hwndSys,   HWND_OBJECT, FALSE );
        ... repeat for FID_MINMAX, etc ...
 }
 else { /* restore controls */
    WinSetParent( hwndTitle, hwndFrame, FALSE );
    WinSetParent( hwndSys, hwndFrame, FALSE );
        ... basically reverse of above ...
 }
 WinSendMsg( hwndFrame, WM_UPDATEFRAME,
      (MPARAM)(FCF_TITLEBAR | FCF_SYSMENU | ...), NULL);
 SizeTheWindow( hwndFrame );
 Hidden = ! Hidden;
 return;
}

Credit: Mike Thompson


[Back: I can't get different colors in text control windows]
[Next: How can I get transparent regions in bitmaps?]