Hiding a Fullscreen App (game)

Excuse my ignorance, i'm quite a novice to programming:)

my problem is i can't get my program to find the appropriate window handle for it to hide/minimize when the game is in fullscreen... it will do it fine in windowed mode (i use process.mainWindowHandle property), but after i fullscreen it (Even if i go back) it won't find the right handle again...

i've seen pieces of code using the FindWindow(string window class, string window name) method from the Windows API (user32.dll) but it will return something well out of the bounds of a window handle (way out of the bounds of an integer :p )

so i made a class that is derived from a process.. i added a method called ToggleState()
(note, hWND is also set to "this.MainWindowHandle" in the constructor of the class)

public void ToggleState()
{

if ( IsWindowVisible(hWND) != 0 )
{
this.hWND = (int) this.MainWindowHandle;
ShowWindow(this.hWND, SW_HIDE );
}

else if ( IsWindowVisible(hWND ) == 0 )
{
ShowWindow(hWND, SW_RESTORE );
SetForegroundWindow(hWND);
}
}

In summary: if i launch the game in windowed mode, it will work indefinately, but then if i fullscreen it (or start in fullscreen) it will cease to function (even if i go back to windowed)

i've tried other alternatives, like creating a new process object and doing GetProcessByName and then getting the main handle of THAT (still no luck)

Thanks for your time anybody who reads this:D
[1587 byte] By [KBirger] at [2007-11-18 16:58:36]