Runtime removing menu and status bar(Hiding)

BlitzMax Forums/BlitzMax GUI Programming/Runtime removing menu and status bar(Hiding)

Hello,

Does somebody knows if it's possible to hide the menu and the status bar from a window without recreating it?

What I am trying to achieve is to have a normal menu/status "windowed" window expand to fullscreen and in this mode have the menu and status disappearing.

some code win32 only
Function SetWindowFullscreen:Int(Window:TGadget)

	Extern "Win32"
		Function SetWindowLong:Int(hWnd:Int, nIndex:Int, dwNewLong:Int)="SetWindowLongA@12"
		Function SetLayeredWindowAttributes(hWnd:Int, temp:Int, alpha:Int, buh:Int)="SetLayeredWindowAttributes@16"
		Function GetWindowLong:Int(hWnd:Int, nIndex:Int)="GetWindowLongA@8"
		Function MoveWindow:Int(hwnd:Int, x:Int, y:Int, nWidth:Int, nHeight:Int, bRepaint:Int)="MoveWindow@24"
		Function GetSystemMetrics:Int (nIndex:Int) = "GetSystemMetrics@4"
		Function SetWindowPos:Int (hwnd:Int, hWndInsertAfter:Int, x:Int, y:Int, cx:Int, cy:Int, wFlags:Int) = "SetWindowPos@28"
	End Extern

	Local hWnd:Int
	Local Style:Int
   
	hWnd = QueryGadget(Window, QUERY_HWND)
   
	If Not hWnd
		Return False
	EndIf
   
   'Style = GetWindowLongA(hWnd, GWL_STYLE)
   'Style:|WS_EX_LAYERED
   
	Const SM_XVIRTUALSCREEN:Int       =76
	Const SM_YVIRTUALSCREEN:Int       =77
	Const SM_CXVIRTUALSCREEN:Int      =78
	Const SM_CYVIRTUALSCREEN:Int      =79
	Const SM_CMONITORS:Int            =80
	Const SM_SAMEDISPLAYFORMAT:Int    =81
	
	Style = WS_VISIBLE
	
	Local window_w:Int = GetSystemMetrics(SM_CXVIRTUALSCREEN)
	Local window_h:Int = GetSystemMetrics(SM_CYVIRTUALSCREEN)

	SetWindowLongA(hWnd, GWL_STYLE, Style)
	MoveWindow(hWnd, (GetSystemMetrics(SM_CXVIRTUALSCREEN) - window_w) / 2, (GetSystemMetrics(SM_CYVIRTUALSCREEN) - window_h) / 2, window_w, window_h, 1)
	Return True

End Function


To remove the menubar:
Extern "Win32"
  Function SetMenu:Int( hwnd:Int, menu:Int)
EndExtern
SetMenu( hwnd, Null)

And the statusbar
Extern "Win32"
	Function FindWindowExA:Int( parent:Int, childafter:Int, classname$z, windowtitle$z)
EndExtern
Local statushwnd:Int = FindWindowExA( hwnd, 0, "msctls_statusbar32", "")
If statushwnd <> 0 Then ShowWindow( statushwnd, SW_HIDE)

Btw you should realy use GetWindowLong to get the style and remove what you dont want, as you never know what flags are set.
Something like...
Style = GetWindowLong( hwnd, GWL_STYLE)  ~ WS_CAPTION ~ WS_BORDER

Hope that helps =)

Thanks for the advice on window's style. The 2 functions work , I can hide or show the status bar however if I hide the menu I can't seem to have it back, is there a way other than recreating it to hide/show the menu?

Yeah, try this:
SetMenu( hwnd, WindowMenu(window).Query(QUERY_HWND))
UpdateWindowMenu(window)


Thanks a lot ... if anybody needs it here are 4 functions (Win32 only). ShowWindowMenu, HideWindowMenu, ShowWindowStatusbar, HideWindowStatusbar

Function ShowWindowMenu:Int(Window:TGadget)
	Extern "Win32"
	  Function SetMenu:Int( hwnd:Int, menu:Int)
	EndExtern
	
	Local hWnd:Int
   
	hWnd = QueryGadget(Window, QUERY_HWND)
   
	If Not hWnd
		Return False
	EndIf

	SetMenu( hwnd, WindowMenu(Window).Query(QUERY_HWND))
	UpdateWindowMenu(Window)
	Return True
End Function

Function HideWindowMenu:Int(Window:TGadget)
	Extern "Win32"
	  Function SetMenu:Int( hwnd:Int, menu:Int)
	EndExtern
	
	Local hWnd:Int

	hWnd = QueryGadget(Window, QUERY_HWND)
   
	If Not hWnd
		Return False
	EndIf
	
	SetMenu( hwnd, Null)
	Return True
End Function

Function ShowWindowStatusbar:Int(Window:TGadget)
	Extern "Win32"
		Function FindWindowExA:Int( parent:Int, childafter:Int, classname$z, windowtitle$z)
	EndExtern
	Local hWnd:Int

	hWnd = QueryGadget(Window, QUERY_HWND)
   
	If Not hWnd
		Return False
	EndIf
	
	Local statushwnd:Int = FindWindowExA( hWnd, 0, "msctls_statusbar32", "")
	
	If statushwnd <> 0
		ShowWindow( statushwnd, SW_SHOW)
		Return True
	EndIf
	
	Return False
End Function

Function HideWindowStatusbar:Int(Window:TGadget)
	Extern "Win32"
		Function FindWindowExA:Int( parent:Int, childafter:Int, classname$z, windowtitle$z)
	EndExtern
	Local hWnd:Int
   
	hWnd = QueryGadget(Window, QUERY_HWND)
   
	If Not hWnd
		Return False
	EndIf
	Local statushwnd:Int = FindWindowExA( hWnd, 0, "msctls_statusbar32", "")
	If statushwnd <> 0
		ShowWindow( statushwnd, SW_HIDE)
		Return True
	EndIf
	Return False
End Function


Anybody knows how to do the same on Mac OS and Linux?

You have SW_HIDE and SW_SHOW switched in the show and hide status bar functions.

I was able to hide the statusbar, but I cannot seem to resize the window client area. Now I just a have a blank spot where the statusbar used to be.

You need maybe to resize your canvas and redraw the window?

Thanks for spotting the switch, edited in above code.

Now I just a have a blank spot where the statusbar used to be.

Any new info on this topic Leadwerks?
I'm experiencing the same thing: I'm trying to have an app going from normal windowed mode to fullscreen mode, but only by maximising the window and hiding stuff, not really switch video mode and the likes.

It works fine, except for the status bar portion at the bottom: the status bar does hide (big thanks to grable and LAB[au]!), but the empty space is always 'blank', i.e.: no gadget can be shown in that area. From looking at the win32 code, I can see that there is in fact *another* window being created when using the WINDOW_STATUS flag in CreateWindow, for a total of 3 windows:
1) The good old visible one with the menu bar and stuff
2) The status bar itself
3) The invisible 'client portion' of the real window minus the status bar height. This is the window actually being used when creating a gadget inside the window.

This is why everything gets clipped at the bottom even when using HideWindowStatusbar trick. It doesn't seem easy to fix, unless MaxGUI would provide functions to alter the style of a window after its creation, such as:
ChangeWindowStyle(add, remove)
i.e.: ChangeWindowStyle(0, WINDOW_STATUS)
would remove the status bar along with every necessary internal stuff to keep the gadget in a consistent state.