Skip to content

Commit

Permalink
pmwin: Added a few WinIs* APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jul 10, 2018
1 parent e31492c commit 8c5d43f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions native/pmwin-lx.h
Expand Up @@ -18,6 +18,9 @@ LX_NATIVE_MODULE_INIT()
LX_NATIVE_EXPORT(WinFillRect, 743),
LX_NATIVE_EXPORT(WinGetLastError, 753),
LX_NATIVE_EXPORT(WinInitialize, 763),
LX_NATIVE_EXPORT(WinIsWindow, 772),
LX_NATIVE_EXPORT(WinIsWindowEnabled, 773),
LX_NATIVE_EXPORT(WinIsWindowVisible, 775),
LX_NATIVE_EXPORT(WinTerminate, 888),
LX_NATIVE_EXPORT(WinPostQueueMsg, 902),
LX_NATIVE_EXPORT(WinCreateStdWindow, 908),
Expand Down
51 changes: 51 additions & 0 deletions native/pmwin.c
Expand Up @@ -78,6 +78,7 @@ typedef struct Window
LONG y;
LONG w;
LONG h;
BOOL enabled;
} Window;

typedef struct MessageQueueItem
Expand Down Expand Up @@ -1624,5 +1625,55 @@ BOOL WinFillRect(HPS hps, PRECTL prcl, LONG lColor)
return TRUE;
} // WinFillRect

BOOL WinIsWindow(HAB hab, HWND hwnd)
{
TRACE_NATIVE("WinIsWindow(%u, %u)", (uint) hab, (uint) hwnd);
FIXME("this 'get the anchor, get the window, set errors' code is repeated a lot");
AnchorBlock *anchor = getAnchorBlockNoHAB();
if (!anchor) {
SET_WIN_ERROR_AND_RETURN(anchor, PMERR_INVALID_HWND, FALSE);
}

Window *win = getWindowFromHWND(anchor, hwnd);
if (!win) {
SET_WIN_ERROR_AND_RETURN(anchor, PMERR_INVALID_HWND, FALSE);
}

return TRUE;
} // WinIsWindow

BOOL WinIsWindowEnabled(HWND hwnd)
{
TRACE_NATIVE("WinIsWindowEnabled(%u)", (uint) hwnd);
AnchorBlock *anchor = getAnchorBlockNoHAB();
if (!anchor) {
SET_WIN_ERROR_AND_RETURN(anchor, PMERR_INVALID_HWND, FALSE);
}

Window *win = getWindowFromHWND(anchor, hwnd);
if (!win) {
SET_WIN_ERROR_AND_RETURN(anchor, PMERR_INVALID_HWND, FALSE);
}

return win->enabled;
} // WinIsWindowEnabled

BOOL WinIsWindowVisible(HWND hwnd)
{
TRACE_NATIVE("WinIsWindowVisible(%u)", (uint) hwnd);
AnchorBlock *anchor = getAnchorBlockNoHAB();
if (!anchor) {
SET_WIN_ERROR_AND_RETURN(anchor, PMERR_INVALID_HWND, FALSE);
}

Window *win = getWindowFromHWND(anchor, hwnd);
if (!win) {
SET_WIN_ERROR_AND_RETURN(anchor, PMERR_INVALID_HWND, FALSE);
}

return ((win->style & WS_VISIBLE) == WS_VISIBLE) ? TRUE : FALSE;
} // WinIsWindowVisible


// end of pmwin.c ...

3 changes: 3 additions & 0 deletions native/pmwin.h
Expand Up @@ -894,6 +894,9 @@ OS2EXPORT BOOL OS2API WinPostQueueMsg(HMQ hmq, ULONG msg, MPARAM mp1, MPARAM mp2
OS2EXPORT HPS OS2API WinBeginPaint(HWND hwnd, HPS hps, PRECTL prclPaint) OS2APIINFO(703);
OS2EXPORT BOOL OS2API WinEndPaint(HPS hps) OS2APIINFO(738);
OS2EXPORT BOOL OS2API WinFillRect(HPS hps, PRECTL prcl, LONG lColor) OS2APIINFO(743);
OS2EXPORT BOOL OS2API WinIsWindow(HAB hab, HWND hwnd) OS2APIINFO(772);
OS2EXPORT BOOL OS2API WinIsWindowEnabled(HWND hwnd) OS2APIINFO(773);
OS2EXPORT BOOL OS2API WinIsWindowVisible(HWND hwnd) OS2APIINFO(775);

#ifdef __cplusplus
}
Expand Down

0 comments on commit 8c5d43f

Please sign in to comment.