How to get valid Window Gadget handle?

BlitzPlus Forums/BlitzPlus Programming/How to get valid Window Gadget handle?

Grey Alien(Posted 2005) [#1]
I have a game that works in full-screen or windowed mode but when it is in windowed mode I am deliberately using Graphics with the Mode flag set to 2 instead of using Create Window. This all works fine and I have managed to put a system menu, minimise and close button on the graphics window with various user32.dll calls.

My problem is I want to detect when the windowed mode has been minimised so that I can stop the music and restart it on restore (is this the same as maximise?).

I tried WindowMinimized(TheWindow) where TheWindow is a handle of the graphics window obtained with a User32.dll call to FindWindowA("",AppName). The handle returned works fine for other user32 calls BUT not for WindowMinimized which errors with "Invalid Windows Gadget handle". I guess that the Blitz command doesn't want the raw windows handle, it wants something else.

So the crunch .. does anyone know how to convert a windows window handle to a blitz window handle or how to get the blitz window handle for the graphics window? I don't want to use CreateWindow as Graphics lets me make proper games with flip, keydown etc.

P.S. sorry for the long explanation, hope you get it.


aab(Posted 2005) [#2]
You can make games with a window that use keydown, flip etc.
Just dont set up and event loop
All you have to do is set the canvasbuffer as the current drawing buffer, and you can still add the gadgets you want through user32, and handle them yourself.

As for Converting the Windows Handle to a Blitz Window Handle :: WindowMinimized() etc, probobly use Blitz C++ Classes so it would involve knowing that class, and creating an instance of one, registering it with blitz etc..

However, According to its state ie: a window may have WS_MINIMIZE show state flag if it is minimized, so use
(GetWindowLong(HWND,GWL_STYLE) AND WS_MINIMIZE)
=>
(GetWindowLong(HWND,-16) AND $20000000L)


Grey Alien(Posted 2005) [#3]
thanks aab, I'll try that to check the window state.


Grey Alien(Posted 2005) [#4]
hmm. Unfortunately your code only tells me if I have a minimize button on the title bar, which I do. I need to detect if the windows IS CURRENTLY minimised or HAS BEEN minimised recently. Any clues?


JoshK(Posted 2005) [#5]
Look it up at msdn.


Grey Alien(Posted 2005) [#6]
In the end I got the answer as posted in this thread: http://www.blitzbasic.com/Community/posts.php?topic=48628