Jump to content

WinIsWindowShowing

From EDM2

This function determines whether any part of the window hwnd is physically visible.

Syntax

WinIsWindowShowing(hwnd)

Parameters

hwnd (HWND) - Input
Window handle.
rc (BOOL) - Returns
TRUE if some part of the window is displayed, FALSE otherwise.

Returns

rc (BOOL) - returns
Showing state indicator.
TRUE
Some part of the window is displayed on the screen.
FALSE
The function returns FALSE if:
No part of the window is displayed on the screen.
The window is disabled.
The window update is disabled.

Remarks

This function is useful for applications that constantly output new information. If it returns FALSE (meaning no part of the window is visible), the application can avoid redrawing, as it would be unnecessary.

Applications using WinIsWindowShowing must call it every time they have new information to update. Failure to do so can result in invalid screen content. Alternatively, a constantly updating application can invalidate its window and redraw within a WinBeginPaint - WinEndPaint sequence.

FALSE is also returned if the Presentation Manager (PM) session is not currently visible.

Errors

Possible returns from WinGetLastError:

  • PMERR_INVALID_HWND (0x1001) - An invalid window handle was specified.

Example Code

#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, Also in COMMON section */
#include <os2.h>

HWND    hwnd; /* Window handle. */
BOOL    rc;   /* Showing state indicator. */

rc = WinIsWindowShowing(hwnd);

This example checks if any part of the window is visible before triggering a redraw.

#define INCL_WINWINDOWMGR    /* Window Manager Functions */
#define INCL_WINFRAMEMGR     /* Window Frame Functions   */
#include <os2.h>

HWND    hwnd;               /* Window handle            */
RECTL   rcl;                /* Update region            */

/* If any part of the window is visible, cause a redraw */
if (WinIsWindowShowing(hwnd))
 {
    WinQueryUpdateRect(hwnd, &rcl);
    WinInvalidateRect(hwnd,    /* Window to invalidate     */
                      &rcl,    /* Invalid rectangle        */
                      FALSE);  /* Do not include children  */
 }

Related Functions