Minimizing a window

Blitz3D Forums/Blitz3D Beginners Area/Minimizing a window

Blitzplotter(Posted 2006) [#1]
I have been grappling with how to minimise the window that my 'main' blitz application is running in to allow the application that I execute from my blitz code to be viewed automatically. Endgraphics returns a message window stating illegal memory address. Is it possible to resize an established window via a button driven event/code instead of via the mouse ?

i.e. at the moment inorder to view my 'other' application's window I have to minimize my original applications window. Is there a command I can insert that is equivalent to clicking on the minimise button at the top of the window ? I have searched the archives for this (simple ?) solution, attempted to implement some of the code I found but Blitz3D didn't seem to recognise it.

I also read that upon starting a separate application that the new app would come to the fore, it displays at the 'back' of the current window.


jfk EO-11110(Posted 2006) [#2]
First you need a file named "user32.delcs" in your userlibs folder. THe userlibs folder is located in the blitz3d installation folder. The file "user32.decls" should be edited with notepad and contain at least:

.lib "user32.dll"
ShowWindow(hwnd%,nCmdShow%)

Now you can use the user32.dll's function "ShowWindow" from within Blitz. This function is used to show, hide, minimize etc. a window.

graphics 640,480,32,2
const SW_SHOWMINIMIZED=6
const SW_SHOWNORMAL=1

hwnd=SystemProperty$("AppHWND")
ShowWindow(hwnd, SW_SWOWMINIMIZED)
delay 2000
ShowWindow(hwnd, SW_SHOWNORMAL)
waitkey()


also have a look at the win32 constants in the code archives, section userlibs.

Note: when your app is running in fullscreen mode, minimizing will pause it and the user will have to manually click it to reactivate it! (The only way around this is to use an external program that will reactivate it and also give it back the focus (I used "mouse_event" to simulate a mouseclick, forcing focus nomatterwhat, but that's an other, pretty hackish chapter).)


jfk EO-11110(Posted 2006) [#3]
BTW. yes, a new App would be the topmost app, but for some reason (at least some time ago, not sure if this is still true) a Blitz app will be forced to stay ontop when you run it from the IDE. When you compile it to an Exe and run the Exe, it will act normally.

You can however manually set a window to be on top or behind other windows by using the user32.dll's function "SetWindowPos". you need to add it to the user32.decls file:
SetWindowPos%(hwnd%,zlevel%,x%,y%,cx%,cy%,wFlags%)

(Note: this is the Function that should be used, other functions like SetForegroundWindow etc sound tasty but don't work for some reason)

See also win32 constants for the required Parameters.

Eg:
show always ontop, no size or position changes:
showWindowPos(hwnd,-1,0,0,100,100,$40 or $203)

show always on bottom:
showWindowPos(hwnd,0,0,0,100,100,$40)

show normal (no forced z-position):
showWindowPos(hwnd,1,0,0,100,100,$40)


Blitzplotter(Posted 2006) [#4]
Thanks for the advice, I forgot how absorbing coding in blitz can be and have been developing a (second application)spelling game for my 6 year old.

There isn't enough hours in the day.....