Finding out if a B3D app is minimised

Blitz3D Forums/Blitz3D Programming/Finding out if a B3D app is minimised

simonh(Posted 2003) [#1]
I need to find out if a B3D app is minimised, what is the easiest way to do this?


Perturbatio(Posted 2003) [#2]
You might be able to do it with the WinAPI GetWindowPlacement (I'm too tired at the moment to figure it out myself).

The GetWindowPlacement function retrieves the show state and the restored, minimized, and maximized positions of the specified window.

BOOL GetWindowPlacement(

HWND hWnd, // handle of window
WINDOWPLACEMENT *lpwndpl // address of structure for position data
);


Parameters

hWnd

Identifies the window.

lpwndpl

Points to the WINDOWPLACEMENT structure that receives the show state and position information.
Before calling GetWindowPlacement, set the length member of the WINDOWPLACEMENT structure to sizeof(
WINDOWPLACEMENT).
GetWindowPlacement fails if lpwndpl->length is not set correctly.



Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The flags member of WINDOWPLACEMENT retrieved by this function is always zero. If the window identified by the hWnd parameter is maximized, the showCmd member is SW_SHOWMAXIMIZED. If the window is minimized, showCmd is SW_SHOWMINIMIZED. Otherwise, it is SW_SHOWNORMAL.
The length member of WINDOWPLACEMENT must be set to sizeof(WINDOWPLACEMENT). If this member is not set correctly, the function returns FALSE.

See Also

SetWindowPlacement, WINDOWPLACEMENT




The WINDOWPLACEMENT structure contains information about the placement of a window on the screen.

typedef struct _WINDOWPLACEMENT { // wndpl
UINT length;
UINT flags;
UINT showCmd;
POINT ptMinPosition;
POINT ptMaxPosition;
RECT rcNormalPosition;
} WINDOWPLACEMENT;


Members

length

Specifies the length, in bytes, of the structure. Before calling the GetWindowPlacement or SetWindowPlacement functions, set this member to sizeof(WINDOWPLACEMENT).

GetWindowPlacement and SetWindowPlacement fail if this member is not set correctly.

flags

Specifies flags that control the position of the minimized window and the method by which the window is restored. This member can be one or both of the following values:



Value Meaning
WPF_RESTORETOMAXIMIZED
Specifies that the restored window will be maximized, regardless of whether it was maximized before it was minimized. This setting is only valid the next time the window is restored. It does not change the default restoration behavior. This flag is only valid when the SW_SHOWMINIMIZED value is specified for the showCmd member.
WPF_SETMINPOSITION
Specifies that the coordinates of the minimized window may be specified. This flag must be specified if the coordinates are set in the ptMinPosition member.


showCmd

Specifies the current show state of the window. This member can be one of the following values:



Value Meaning
SW_HIDE Hides the window and activates another window.
SW_MINIMIZE Minimizes the specified window and activates the top-level window in the system's list.
SW_RESTORE Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position (same as SW_SHOWNORMAL).
SW_SHOW Activates a window and displays it in its current size and position.
SW_SHOWMAXIMIZED Activates a window and displays it as a maximized window.
SW_SHOWMINIMIZED Activates a window and displays it as an icon.
SW_SHOWMINNOACTIVE Displays a window as an icon. The active window remains active.
SW_SHOWNA Displays a window in its current state. The active window remains active.
SW_SHOWNOACTIVATE Displays a window in its most recent size and position. The active window remains active.
SW_SHOWNORMAL Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position (same as SW_RESTORE).


ptMinPosition

Specifies the coordinates of the window's upper-left corner when the window is minimized.

ptMaxPosition

Specifies the coordinates of the window's upper-left corner when the window is maximized.

rcNormalPosition

Specifies the window's coordinates when the window is in the restored position.



See Also

ShowWindow, POINT, RECT



skidracer(Posted 2003) [#3]
I don't think full screen modes have a minimized state, the app get's paused and you need to test for a healthy pause between flips to recognize your app has become unpaused.

To test if a window is minimized use IsIconic(hwnd).


sswift(Posted 2003) [#4]
search forums for "hasfocus". We already discussed how to dtermine if an app has focus, and if a fullscreen app is tabbed out of then it no longer has focus.