How to get valid Window Gadget handle?

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

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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.