How to maximize a window without showing it?

BlitzMax Forums/OpenGL Module/How to maximize a window without showing it?

Odds On(Posted 2005) [#1]
Is it possible to set a window to it's maximized state while it's hidden, without showing it even for a split second?

Basically I want to be able to something like this:

// create window
// maximize window
// create gadgets etc
// show window

Regards,
Chris


Perturbatio(Posted 2005) [#2]
It's certainly possible in windows (using SetWindowLong and WS_MAXIMIZE), but I don't know about Linux or Osx


Odds On(Posted 2005) [#3]
Spot on! Thanks Perturbatio :)


Perturbatio(Posted 2005) [#4]
np, at a guess, to do it in linux, you would use this:
http://tronche.com/gui/x/xlib/window/configure.html


Odds On(Posted 2005) [#5]
SetWindowLong() doesn't appear to do the job 100% unless I'm doing something wrong.. it certainly sets the window to it's maximized state, but it doesn't fill the screen after doing so.

I could use SetWindowPos( ) to do it manually but then I can't restore the window down to it's original size because it forgets the old position and size of the window.

Regards,
Chris


Perturbatio(Posted 2005) [#6]
I *think* you would need to use RedrawWindow.

Either that or GetSystemMetrics to get screen Width and Height and then InvalidateRect or InvalidateRgn to redraw.


fredborg(Posted 2005) [#7]
You need to make sure that the 'content of the window' ie. the canvas has at least the same dimensions as the window when it's maximized. If the content is smaller, it won't display.


Smokey(Posted 2005) [#8]
It is possible to add close button and minimize button also?

The bglCreateContext does't seem to have flag for this
or we must use the user32.dll fonction to add them ?


JoshK(Posted 2006) [#9]
It's pretty complicated, but it is possible:
Extern "win32"
	Function SetWindowLong:Int(hwnd:Int,index:Int,value:Int)="SetWindowLongA@12"
	Function GetWindowLong:Int(hWnd:Int, index:Int)="GetWindowLongA@8"
	Function SystemParametersInfoA(a,b,c:Byte Ptr,d)
EndExtern

Type WINDOWPLACEMENT
    Field length:Int=44
    Field flags:Int=0
    Field showCmd:Int=SW_SHOWNA
    Field ptMinPosition0:Int
    Field ptMinPosition1:Int
    Field ptMaxPosition0:Int
    Field ptMaxPosition1:Int
    Field rcNormalPosition0:Int
    Field rcNormalPosition1:Int
    Field rcNormalPosition2:Int
    Field rcNormalPosition3:Int
EndType

hwnd=QueryGadget(window,QUERY_HWND)
Local rect[4]
SystemParametersInfoA(48,0,rect,0)
lpwndpl:WINDOWPLACEMENT=New WINDOWPLACEMENT
GetWindowPlacement(hwnd,lpwndpl)
lpwndpl.showCmd=SW_HIDE
SetWindowLong hwnd,GWL_STYLE,getwindowlong(hwnd,GWL_STYLE)+WS_MAXIMIZE
SetGadgetShape window,rect[0],rect[1],rect[2]-rect[0],rect[3]-rect[1]
SetWindowPlacement(hwnd,lpwndpl)	
lpwndpl=Null


This can also be used to set the restore size of a maximized or minimized window, without actuall restoring the window.


xlsior(Posted 2008) [#10]
sorry for dragging up such an old thread, the but code above looked relevant to something I'm working on at the moment... However, when I try to run Leadwerk's code above, it fails with an error:
Compile Error - Identifier 'GetWindowPlacement' not found on the line: GetWindowPlacement(hwnd,lpwndpl)


I tried adding the following two lines to the Extern block:

	Function GetwindowPlacement(hwnd:Int,lpwndpl:Byte Ptr)
	Function SetwindowPlacement(hwnd:Int,lpwndpl:Byte Ptr)


But doing that gives me the following errors on compile:

j://.bmx/windowplacement.bmx.console.release.win32.x86.o: undefined reference to `GetwindowPlacement@8'
j://.bmx/windowplacement.bmx.console.release.win32.x86.o: undefined reference to `SetwindowPlacement@8'



And ideas?


SebHoll(Posted 2008) [#11]
You need to make sure you Import Pub.Win32 if you want to access any API functions. The code below is slightly tweaked so that it compiles:

Import Pub.Win32
Import MaxGUI.Drivers

Extern "win32"
	Function GetWindowPlacement:Int( hWnd:Int, lpwndpl:Byte Ptr )
	Function SetWindowPlacement:Int( hWnd:Int, lpwndpl:Byte Ptr )
	Function SystemParametersInfoA:Int(a,b,c:Byte Ptr,d)
EndExtern

Type WINDOWPLACEMENT
    Field length:Int=44
    Field flags:Int=0
    Field showCmd:Int=SW_SHOWNA
    Field ptMinPosition0:Int
    Field ptMinPosition1:Int
    Field ptMaxPosition0:Int
    Field ptMaxPosition1:Int
    Field rcNormalPosition0:Int
    Field rcNormalPosition1:Int
    Field rcNormalPosition2:Int
    Field rcNormalPosition3:Int
EndType

hwnd=QueryGadget(window,QUERY_HWND)
Local rect[4]
SystemParametersInfoA(48,0,rect,0)
lpwndpl:WINDOWPLACEMENT=New WINDOWPLACEMENT
GetWindowPlacement(hwnd,lpwndpl)
lpwndpl.showCmd=SW_HIDE
SetWindowLongA hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE)+WS_MAXIMIZE
SetGadgetShape window,rect[0],rect[1],rect[2]-rect[0],rect[3]-rect[1]
SetWindowPlacement(hwnd,lpwndpl)	
lpwndpl=Null