From 8c5d43f997b13591fb911bb21bdba619821d28aa Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 10 Jul 2018 01:27:30 -0400 Subject: [PATCH] pmwin: Added a few WinIs* APIs. --- native/pmwin-lx.h | 3 +++ native/pmwin.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++ native/pmwin.h | 3 +++ 3 files changed, 57 insertions(+) diff --git a/native/pmwin-lx.h b/native/pmwin-lx.h index 6b202bb..839c892 100644 --- a/native/pmwin-lx.h +++ b/native/pmwin-lx.h @@ -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), diff --git a/native/pmwin.c b/native/pmwin.c index 3c412e5..66bfe62 100644 --- a/native/pmwin.c +++ b/native/pmwin.c @@ -78,6 +78,7 @@ typedef struct Window LONG y; LONG w; LONG h; + BOOL enabled; } Window; typedef struct MessageQueueItem @@ -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 ... diff --git a/native/pmwin.h b/native/pmwin.h index aa1d21e..1b0f114 100644 --- a/native/pmwin.h +++ b/native/pmwin.h @@ -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 }