pmwin: Added a few WinIs* APIs.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 10 Jul 2018 01:27:30 -0400
changeset 150 71400eb2cadf
parent 149 c0dff550146e
child 151 de653a557d8c
pmwin: Added a few WinIs* APIs.
native/pmwin-lx.h
native/pmwin.c
native/pmwin.h
--- a/native/pmwin-lx.h	Tue Jul 10 01:26:40 2018 -0400
+++ b/native/pmwin-lx.h	Tue Jul 10 01:27:30 2018 -0400
@@ -18,6 +18,9 @@
     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),
--- a/native/pmwin.c	Tue Jul 10 01:26:40 2018 -0400
+++ b/native/pmwin.c	Tue Jul 10 01:27:30 2018 -0400
@@ -78,6 +78,7 @@
     LONG y;
     LONG w;
     LONG h;
+    BOOL enabled;
 } Window;
 
 typedef struct MessageQueueItem
@@ -1624,5 +1625,55 @@
     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 ...
 
--- a/native/pmwin.h	Tue Jul 10 01:26:40 2018 -0400
+++ b/native/pmwin.h	Tue Jul 10 01:27:30 2018 -0400
@@ -894,6 +894,9 @@
 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
 }