home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cenvi23.zip / WINTOOLS.LIB < prev    next >
Text File  |  1995-04-10  |  22KB  |  583 lines

  1. // WinTools.lib - Functions for setting the state of of PM windows.  This
  2. // ver.3          file may be #included into other Cmm source files, or
  3. //                you can cut and paste in the parts that you need.
  4. //
  5. //                Note: Most of these routines require either a window
  6. //                handle or a window title.  You can use either, but
  7. //                using a Window handle is a little quicker.  Many of these
  8. //                utilities require that you include PMdll.lib.
  9. //
  10. //
  11. //***** GetWindowHandle(): Get the handle for this window
  12. // SYNTAX: int GetWindowHandle(int WindowHandle)
  13. //         int GetWindowHandle(string WindowTitle[,FullLength])
  14. // WHERE: WindowHandle: Integer identifier for this window
  15. //        WindowTitle: Partial text title of the window (case-insensitive)
  16. //        FullLength: If specified and true then WindowTitle length must be
  17. //                    match fully (still case-insensitive) else only needs to
  18. //                    match for length of WindowTitle; default False for partial match
  19. // RETURN: Returns Window handle for a Windows whose partial title is
  20. //         WindowTitle. Comparison is case-insensitive.  If WindowTitle
  21. //         is not found then returns 0 (NULL).
  22. // NOTE: If WindowHandle is input, then this returns WindowHandle if
  23. //       WindowHandle is valid, else returns 0.  WindowTitle is a partial
  24. //       and case-insensitive match and so "write" would match the
  25. //       window titled "Write - THESIS.WRI".
  26. //
  27. //
  28. //***** GetFocusChild(): Get the handle for child that last had focus
  29. // SYNTAX: int GetWindowHandle(int WindowHandle)
  30. //         int GetWindowHandle(string WindowTitle)
  31. // WHERE: WindowHandle: Integer identifier for this window
  32. //        WindowTitle: Partial text title of the window (case-insensitive)
  33. // RETURN: Returns Window handle for a child of this window that now has
  34. //         focus or most recently had focus before this window was
  35. //         made inactive.  NULL if not focus child.
  36. // NOTE: If WindowHandle is input, then this returns WindowHandle if
  37. //       WindowHandle is valid, else returns 0.  WindowTitle is a partial
  38. //       and case-insensitive match and so "write" would match the
  39. //       window titled "Write - THESIS.WRI".
  40. //
  41. //
  42. //***** GetFocus(): Return window handle with current (keyboard) focus
  43. // SYNTAX: int GetFocus()
  44. // RETURN: handle of window with focus
  45. //
  46. //
  47. //***** GetWindowTitle(): Get full Window Title
  48. // SYNTAX: string GetWindowTitle(int WindowHandle)
  49. //         string GetWindowTitle(string WindowTitle)
  50. // WHERE: WindowHandle: Integer identifier for this window
  51. //        WindowTitle: Partial text title of the window (case-insensitive)
  52. // RETURN: Returns Full title for this window, or NULL if window not
  53. //         found or title not found
  54. //
  55. //
  56. //***** SetWindowTitle(): Set title for window
  57. // SYNTAX: bool SetWindowTitle(int WindowHandle,string NewTitle)
  58. //         bool SetWindowTitle(string WindowTitle,string NewTitle)
  59. // WHERE: WindowHandle: Integer identifier for this window
  60. //        WindowTitle: Partial text title of the window (case-insensitive)
  61. //        NewTitle: New full title for this window
  62. // RETURN: TRUE if successful, else FALSE if WindowSpec is invalid.
  63. //
  64. //
  65. //***** IsWindow(): Is this a valid window title or handle
  66. // SYNTAX: bool IsWindow(int WindowHandle)
  67. //         bool IsWindow(string WindowTitle)
  68. // WHERE: WindowHandle: Integer identifier for this window
  69. //        WindowTitle: Partial text title of the window (case-insensitive)
  70. // RETURN: Returns non-zero if this window exists, else returns zero (FALSE)
  71. //
  72. //
  73. //***** IsMinimized(): Is window minimized (Iconic)
  74. // SYNTAX: bool IsMinimized(int WindowHandle)
  75. //         bool IsMinimized(string WindowTitle)
  76. // WHERE: WindowHandle: Integer identifier for this window
  77. //        WindowTitle: Partial text title of the window (case-insensitive)
  78. // RETURN: non-zero if Window is minimized (iconic) else zero (FALSE)
  79. //         if not minimized or if WindowSpec is invalid
  80. //
  81. //
  82. //***** IsMaximized(): Is window maximized
  83. // SYNTAX: bool IsMinimized(int WindowHandle)
  84. //         bool IsMinimized(string WindowTitle)
  85. // WHERE: WindowHandle: Integer identifier for this window
  86. //        WindowTitle: Partial text title of the window (case-insensitive)
  87. // RETURN: non-zero if Window is maximized else zero (FALSE) if not
  88. //         maximized or if WindowSpec is invalid
  89. //
  90. //
  91. //***** IsVisible(): Is window visible
  92. // SYNTAX: bool IsVisible(int WindowHandle)
  93. //         bool IsVisible(string WindowTitle)
  94. // WHERE: WindowHandle: Integer identifier for this window
  95. //        WindowTitle: Partial text title of the window (case-insensitive)
  96. // RETURN: non-zero if Window is visible else zero (FALSE) if not
  97. //         visible or if WindowSpec is invalid. Visible means that
  98. //         the window exists on the screen even if it is covered by
  99. //         other windows
  100. //
  101. //
  102. //***** IsEnabled(): Is window enabled for input
  103. // SYNTAX: bool IsEnabled(int WindowHandle)
  104. //         bool IsEnabled(string WindowTitle)
  105. // WHERE: WindowHandle: Integer identifier for this window
  106. //        WindowTitle: Partial text title of the window (case-insensitive)
  107. // RETURN: non-zero if Window is enabled for mouse and keyboard input,
  108. //         else zero (FALSE) if not enabled or if WindowSpec is invalid
  109. //
  110. //
  111. //***** GetWindowRect(): Get current window coordinates
  112. // SYNTAX: bool GetWindowRect(int WindowHandle | string WindowTitle,struct Rectangle)
  113. //         bool GetWindowRect(int WindowHandle | string WindowTitle,
  114. //                            int Left,int Top,int Right,int Bottom)
  115. // WHERE: WindowHandle: Integer identifier for this window
  116. //        WindowTitle: Partial text title of the window (case-insensitive)
  117. //        Rectangle: receive structure of current window with following members
  118. //             .left - coordinate for left edge of window
  119. //             .right - coordinate for right edge of window
  120. //             .top - coordinate for top edge of window
  121. //             .bottom - coordinate for bottom edge of window
  122. //        Left, Top, Right, Bottom - Return these four coordinates
  123. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  124. // MODIFY: Modifies Rectangle structure to current coordinates
  125. //
  126. //
  127. //***** SetWindowRect(): Set current window coordinates
  128. // SYNTAX: bool SetWindowRect(int WindowHandle | string WindowTitle,struct Rectangle)
  129. //         bool SetWindowRect(int WindowHandle | string WindowTitle,
  130. //                            int Left,int Top,int Right,int Bottom)
  131. // WHERE: WindowHandle: Integer identifier for this window
  132. //        WindowTitle: Partial text title of the window (case-insensitive)
  133. //        Rectangle: new structurw of window with the same member elements as
  134. //                   defined above in GetWindowRect()
  135. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  136. //
  137. //
  138. //***** GetScreenSize(): Get width and height of the windows screen
  139. // SYNTAX: void GetScreenSize(int Width,int Height);
  140. // WHERE: Width: receive screen width
  141. //        Height: receive screen height
  142. // MODIFY: Sets Width and Height to dimensions of screen
  143. //
  144. //
  145. //***** GetSize(): Get current width and height of window
  146. // SYNTAX: bool GetSize(int WindowHandle,int Width,int Height)
  147. //         bool GetSize(string WindowTitle,int Width,int Height)
  148. // WHERE: WindowHandle: Integer identifier for this window
  149. //        WindowTitle: Partial text title of the window (case-insensitive)
  150. //        Width: receive current window width
  151. //        Height: receive current window height
  152. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  153. // MODIFY: Sets Width and Height to current dimensions of window
  154. //
  155. //
  156. //***** SetSize(): Get current width and height of window
  157. // SYNTAX: bool GetSize(int WindowHandle,int Width,int Height)
  158. //         bool GetSize(string WindowTitle,int Width,int Height)
  159. // WHERE: WindowHandle: Integer identifier for this window
  160. //        WindowTitle: Partial text title of the window (case-insensitive)
  161. //        Width: new window width
  162. //        Height: new window height
  163. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  164. //
  165. //
  166. //***** GetPosition(): Get current column and row of window
  167. // SYNTAX: bool GetPosition(int WindowHandle,int LeftCol,int BottomRow)
  168. //         bool GetPosition(string WindowTitle,int LeftCol,int BottomRow)
  169. // WHERE: WindowHandle: Integer identifier for this window
  170. //        WindowTitle: Partial text title of the window (case-insensitive)
  171. //        LeftCol: receive current column coordinate of lower-left corner of window
  172. //        Height: receive current row coordinate of lower-left corner of window
  173. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  174. // MODIFY: Sets LeftCol and BottomRow to current lower-left corner coordinates
  175. //
  176. //
  177. //***** SetPosition(): Get current column and row of window
  178. // SYNTAX: bool SetPosition(int WindowHandle,int LeftCol,int BottomRow)
  179. //         bool SetPosition(string WindowTitle,int LeftCol,int BottomRow)
  180. // WHERE: WindowHandle: Integer identifier for this window
  181. //        WindowTitle: Partial text title of the window (case-insensitive)
  182. //        LeftCol: new column coordinate of lower-left corner of window
  183. //        Height: new row coordinate of lower-left corner of window
  184. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  185. //
  186. //
  187. //***** ShowWindow(): Set the way the window is shown (or not shown)
  188. // SYNTAX: bool ShowWindow(int WindowHandle,int ShowCommand)
  189. //         bool ShowWindow(string WindowTitle,int ShowCommand)
  190. // WHERE: WindowHandle: Integer identifier for this window
  191. //        WindowTitle: Partial text title of the window (case-insensitive)
  192. //        ShowCommand: Any of the following values:
  193.       #define SW_HIDE            0  // Hide window; make NOT the active window
  194.       #define SW_MINIMIZE        6  // minimize window; make NOT the active window
  195.       #define SW_RESTORE         9  // activate and display this window; restore from minimized
  196.                                     // or maximized to original size and position before
  197.                                     // it was minimized or maximized
  198.       #define SW_RESTORENOACTIVE (-9) // Same as restore but active window remains active
  199.       #define SW_SHOW            5  // Activate this window in current size and position
  200.       #define SW_SHOWMAXIMIZED   3  // Activate this window and maximize
  201.       #define SW_SHOWMAXNOACTIVE (-3) // Display maximized; active window stays active
  202.       #define SW_SHOWMINIMIZED   2  // Activate this window and display as icon
  203.       #define SW_SHOWMINNOACTIVE 7  // Display as icon; active window stays active
  204.       #define SW_SHOWNA          8  // don't change window state or active window
  205.       #define SW_SHOWNOACTIVATE  4  // display in recent size and place; active window stays active
  206.       #define SW_SHOWNORMAL      1  // same as SW_RESTORE
  207. //
  208. //
  209. //***** GetActiveWindow(): Get the active window
  210. // SYNTAX: int GetActiveWindow()
  211. // RETURN: Return window handle for currently active window
  212. //
  213. //
  214. //***** SetActiveWindow(): Set the currently active window
  215. // SYNTAX: bool SetActiveWindow(int WindowHandle)
  216. //         bool SetActiveWindow(string WindowTitle)
  217. // WHERE: WindowHandle: Integer identifier for this window
  218. //        WindowTitle: Partial text title of the window (case-insensitive)
  219. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  220. //
  221. //
  222. //***** CloseWindow(): Send a CLOSE message to this window
  223. // SYNTAX: bool CloseWindow(int WindowHandle)
  224. //         bool CloseWindow(string WindowTitle)
  225. // WHERE: WindowHandle: Integer identifier for this window
  226. //        WindowTitle: Partial text title of the window (case-insensitive)
  227. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  228. //
  229. //
  230. //***** WinQueryWindow(): Return handle of related window
  231. // SYNTAX: int WinQueryWindow(int Hwnd,int RelationshipCode)
  232. // WHERE: Hwnd: Known handle of existing window
  233. //        RelationshipCode: relationship of window wanted, may be:
  234.    #define QW_NEXT         0
  235.    #define QW_PREV         1
  236.    #define QW_TOP          2
  237.    #define QW_BOTTOM       3
  238.    #define QW_OWNER        4
  239.    #define QW_PARENT       5
  240.    #define QW_NEXTTOP      6
  241.    #define QW_PREVTOP      7
  242.    #define QW_FRAMEOWNER   8
  243. // RETURN: Return related window handle
  244. //
  245. //
  246.  
  247.  
  248. #include <PMdll.lib>
  249.  
  250. #define HWND_DESKTOP 1
  251.  
  252. /*******************************************************************
  253.  *********        END OF DESCRIPTION FOR WINSET.LIB        *********
  254.  *******************************************************************/
  255.  
  256.  
  257. GetWindowHandle(pWindowSpec,pFullLength)
  258. {
  259.    lHwnd = 0;  // assume failure
  260.    // Test if input is string (WindowTitle) or integer (WindowHandle)
  261.    if ( 0 == DataDimension(pWindowSpec) ) {
  262.       // Input is WindowHandle.  Verify that this handle is valid
  263.       #define ORD_WIN32ISWINDOW  772
  264.       if ( HWND_DESKTOP == pWindowSpec
  265.         || PMDynamicLink("PMWIN",ORD_WIN32ISWINDOW,BIT32,CDECL,PMInfo().hab,pWindowSpec) )
  266.          lHwnd = pWindowSpec;
  267.    } else {
  268.       // Input is WindowTitle, look through top level windows for one with this title
  269.       lTitleLen = strlen(pWindowSpec);
  270.       if ( 1 < va_arg()  &&  pFullLength )
  271.          lTitleLen++;
  272.       lEnum = WinBeginEnumWindows(HWND_DESKTOP);
  273.       while ( lChild = WinGetNextWindow(lEnum) ) {
  274.          if ( (lTitle = GetWindowTitle(lChild))  &&  !strnicmp(lTitle,pWindowSpec,lTitleLen) ) {
  275.             lHwnd = lChild;
  276.             break;
  277.          }
  278.       }
  279.       WinEndEnumWindows(lEnum);
  280.    }
  281.    return lHwnd;
  282. }
  283.  
  284.  
  285. GetWindowTitle(WindowSpec)
  286. {
  287.    if ( (_handle = GetWindowHandle(WindowSpec)) ) {
  288.       #define ORD_WIN32QUERYWINDOWTEXT 841
  289.       BLObSize(_buf,200);
  290.       if ( PMDynamicLink("PMWIN",ORD_WIN32QUERYWINDOWTEXT,BIT32,CDECL,_handle,199,_buf) ) {
  291.          strcpy(_ret,_buf);
  292.          return(_ret);
  293.       }
  294.    }
  295.    return(NULL);
  296. }
  297.  
  298. SetWindowTitle(WindowSpec,NewTitle)
  299. {
  300.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  301.       return(FALSE);
  302.    #define ORD_WIN32SETWINDOWTEXT   877
  303.    PMDynamicLink("PMWIN",ORD_WIN32SETWINDOWTEXT,BIT32,CDECL,_handle,NewTitle);
  304.    return(TRUE);
  305. }
  306.  
  307.  
  308. IsWindow(WindowSpec)
  309. {
  310.    return( GetWindowHandle(WindowSpec) );
  311. }
  312.  
  313.  
  314. #define SWP_SIZE              0x0001
  315. #define SWP_MOVE              0x0002
  316. #define SWP_ZORDER            0x0004
  317. #define SWP_SHOW              0x0008
  318. #define SWP_HIDE              0x0010
  319. #define SWP_NOREDRAW          0x0020
  320. #define SWP_NOADJUST          0x0040
  321. #define SWP_ACTIVATE          0x0080
  322. #define SWP_DEACTIVATE        0x0100
  323. #define SWP_EXTSTATECHANGE    0x0200
  324. #define SWP_MINIMIZE          0x0400
  325. #define SWP_MAXIMIZE          0x0800
  326. #define SWP_RESTORE           0x1000
  327. #define SWP_FOCUSACTIVATE     0x2000
  328. #define SWP_FOCUSDEACTIVATE   0x4000
  329.  
  330. QueryWinFlags(pWindowSpec)  // return WinPos flags for this window
  331. {                          // return 0 if no good
  332.    if ( (_handle = GetWindowHandle(pWindowSpec)) ) {
  333.       #define SWP_BLOB_SIZE 9 * 4
  334.       BLObSize(_swp,SWP_BLOB_SIZE);
  335.       #define ORD_WIN32QUERYWINDOWPOS  837
  336.       if ( PMDynamicLink("PMWIN",ORD_WIN32QUERYWINDOWPOS,BIT32,CDECL,_handle,_swp) )
  337.          return(BLObGet(_swp,0,UWORD32));
  338.    }
  339.    return(0);
  340. }
  341.  
  342. IsMinimized(pWindowSpec)
  343. {
  344.    return( QueryWinFlags(pWindowSpec) & SWP_MINIMIZE );
  345. }
  346.  
  347.  
  348. IsMaximized(pWindowSpec)
  349. {
  350.    return( QueryWinFlags(pWindowSpec) & SWP_MAXIMIZE );
  351. }
  352.  
  353.  
  354.  
  355. IsVisible(pWindowSpec)
  356. {
  357.    #define ORD_WIN32ISWINDOWVISIBLE 775
  358.    return( (_handle = GetWindowHandle(pWindowSpec))
  359.          ? PMDynamicLink("PMWIN",ORD_WIN32ISWINDOWVISIBLE,BIT32,CDECL,_handle)
  360.          : FALSE );
  361. }
  362.  
  363.  
  364. IsEnabled(pWindowSpec)
  365. {
  366.    #define ORD_WIN32ISWINDOWENABLED 773
  367.    return( (_handle = GetWindowHandle(pWindowSpec))
  368.          ? PMDynamicLink("PMWIN",ORD_WIN32ISWINDOWENABLED,BIT32,CDECL,_handle)
  369.          : FALSE );
  370. }
  371.  
  372.  
  373. SetWindowPos(pHandle,pBehindHandle,pColumn,pRow,pWidth,pHeight,pFlags)
  374. {
  375.    #define ORD_WIN32SETWINDOWPOS 875
  376.    PMDynamicLink("PMWIN",ORD_WIN32SETWINDOWPOS,BIT32,CDECL,
  377.                  pHandle,pBehindHandle,pColumn,pRow,pWidth,pHeight,pFlags);
  378. }
  379.  
  380.  
  381. GetWindowRect(pWindowSpec,pRectangleOrLeft,pTop,pRight,pBottom)
  382. {
  383.    if ( !(lHwnd = GetWindowHandle(pWindowSpec)) )
  384.       return(FALSE);
  385.    #define SWP_BLOB_SIZE 9 * 4
  386.    BLObSize(lSwp,SWP_BLOB_SIZE);
  387.    #define ORD_WIN32QUERYWINDOWPOS  837
  388.    if ( !DynamicLink("PMWIN",ORD_WIN32QUERYWINDOWPOS,BIT32,CDECL,lHwnd,lSwp) )
  389.       return(FALSE);
  390.    lHeight = BLObGet(lSwp,4,SWORD32);
  391.    lWidth = BLObGet(lSwp,8,SWORD32);
  392.    lBottom = BLObGet(lSwp,12,SWORD32);
  393.    lLeft = BLObGet(lSwp,16,SWORD32);
  394.    lTop = lBottom + lHeight - 1;
  395.    lRight = lLeft + lWidth - 1;
  396.    if ( 2 == va_arg() )
  397.       pRectangleOrLeft.left = lLeft, pRectangleOrLeft.right = lRight,
  398.       pRectangleOrLeft.top = lTop, pRectangleOrLeft.bottom = lBottom;
  399.    else
  400.       pRectangleOrLeft = lLeft, pRight = lRight, pTop = lTop, pBottom = lBottom;
  401.    return(TRUE);
  402. }
  403.  
  404.  
  405. SetWindowRect(pWindowSpec,pRectangleOrLeft,pTop,pRight,pBottom)
  406. {
  407.    if ( !(lHwnd = GetWindowHandle(pWindowSpec)) )
  408.       return(FALSE);
  409.    if ( 2 == va_arg() )
  410.       lLeft = pRectangleOrleft.left, lRight = pRectangleOrleft.right,
  411.       lTop = pRectangleOrleft.top, lBottom = pRectangleOrleft.bottom;
  412.    else
  413.       lLeft = pRectangleOrleft, lRight = pRight, lTop = pTop, lBottom = pBottom;
  414.    SetWindowPos(lHwnd,0,lLeft,lBottom,lRight - lLeft + 1,lTop - lBottom + 1,
  415.                 SWP_SIZE | SWP_MOVE);
  416.    return(TRUE);
  417. }
  418.  
  419.  
  420. GetScreenSize(pWidth,pHeight)
  421. {
  422.    GetSize(HWND_DESKTOP,pWidth,pHeight);
  423. }
  424.  
  425.  
  426. GetSize(pWindowSpec,pWidth,pHeight)
  427. {
  428.    if ( !GetWindowRect(pWindowSpec,lRect) )
  429.       return(FALSE);
  430.    pWidth = lRect.right - lRect.left + 1;
  431.    pHeight = lRect.top - lRect.bottom + 1;
  432.    return(TRUE);
  433. }
  434.  
  435.  
  436. SetSize(WindowSpec,Width,Height)
  437. {
  438.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  439.       return(FALSE);
  440.    SetWindowPos(_handle,0,0,0,Width,Height,SWP_SIZE);
  441.    return(TRUE);
  442. }
  443.  
  444.  
  445. GetPosition(WindowSpec,LeftCol,BottomRow)
  446. {
  447.    if ( !GetWindowRect(WindowSpec,_rect) )
  448.       return(FALSE);
  449.    LeftCol = _rect.left;
  450.    BottomRow = _rect.bottom;
  451.    return(TRUE);
  452. }
  453.  
  454.  
  455. SetPosition(WindowSpec,LeftCol,BottomRow)
  456. {
  457.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  458.       return(FALSE);
  459.    SetWindowPos(_handle,0,LeftCol,BottomRow,0,0,SWP_MOVE | SWP_NOADJUST);
  460.    return(TRUE);
  461. }
  462.  
  463.  
  464. ShowWindow(pWindowSpec,pCmdShow)
  465. {
  466.    if ( !(lHwnd = GetWindowHandle(pWindowSpec)) )
  467.       return(FALSE);
  468.    _active = 0;
  469.    switch( pCmdShow ) {
  470.       case SW_HIDE:
  471.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_HIDE);
  472.          break;
  473.       case SW_SHOWNOACTIVATE:
  474.          _active = GetActiveWindow();
  475.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_SHOW);
  476.          break;
  477.       case SW_MINIMIZE:
  478.       case SW_SHOWMINNOACTIVE:
  479.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_MINIMIZE);
  480.          break;
  481.       case SW_SHOWMINIMIZED:
  482.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_MINIMIZE | SWP_ACTIVATE);
  483.          break;
  484.       case SW_SHOWMAXNOACTIVE:
  485.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_MAXIMIZE);
  486.          break;
  487.       case SW_SHOWMAXIMIZED:
  488.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_MAXIMIZE | SWP_ACTIVATE);
  489.          break;
  490.       case SW_RESTORENOACTIVE:
  491.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_RESTORE);
  492.          break;
  493.       case SW_RESTORE:
  494.       case SW_SHOWNORMAL:
  495.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_RESTORE | SWP_ACTIVATE);
  496.          break;
  497.       case SW_SHOW:
  498.          SetActiveWindow(lHwnd);
  499.          break;
  500.       case SW_SHOWNA:
  501.          break;
  502.       default: return(FALSE);
  503.    }
  504.    if ( _active )
  505.       SetActiveWindow(_active);
  506.    return(TRUE);
  507. }
  508.  
  509.  
  510. GetActiveWindow()
  511. {
  512.    #define ORD_WIN32QUERYACTIVEWINDOW  799
  513.    return PMDynamicLink("PMWIN",ORD_WIN32QUERYACTIVEWINDOW,BIT32,CDECL,HWND_DESKTOP);
  514. }
  515.  
  516.  
  517. SetActiveWindow(WindowSpec)
  518. {
  519.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  520.       return(FALSE);
  521.    SetWindowPos(_handle,0,0,0,0,0,SWP_ACTIVATE);
  522.    return(TRUE);
  523. }
  524.  
  525. CloseWindow(WindowSpec)
  526. {
  527.    if ( !(lHwnd = GetWindowHandle(WindowSpec)) )
  528.       return(FALSE);
  529.    #define ORD_WIN32POSTMSG   919
  530.    #define WM_CLOSE           0x0029
  531.    DynamicLink("PMWIN",ORD_WIN32POSTMSG,BIT32,CDECL,lHwnd,WM_CLOSE,0,0);
  532.    return(TRUE);
  533. }
  534.  
  535. GetFocusChild(WindowSpec)
  536. {
  537.    if ( !(lHandle = GetWindowHandle(WindowSpec)) )
  538.       return(FALSE);
  539.    if ( lHandle == GetActiveWindow() ) {
  540.       // This is currently the active window, so just get the focus window
  541.       return GetFocus();
  542.    } else {
  543.       // This window is not currently active, so get what the active window
  544.       // used to be.
  545.       #define QWL_HWNDFOCUSSAVE           0x0018
  546.       #define ORD_WIN32QUERYWINDOWULONG   843
  547.       return PMDynamicLink("PMWIN",ORD_WIN32QUERYWINDOWULONG,BIT32,CDECL,
  548.                            lHandle,QWL_HWNDFOCUSSAVE);
  549.    }
  550. }
  551.  
  552. WinQueryWindow(pHwnd,pRelationship)
  553. {
  554.    #define ORD_WIN32QUERYWINDOW  834
  555.    return PMDynamicLink("PMWIN",ORD_WIN32QUERYWINDOW,BIT32,CDECL,
  556.                         pHwnd,pRelationship);
  557. }
  558.  
  559. WinBeginEnumWindows(pHwndParent)
  560. {
  561.    #define ORD_WIN32BEGINENUMWINDOWS   702
  562.    return DynamicLink("PMWIN",ORD_WIN32BEGINENUMWINDOWS,BIT32,CDECL,pHwndParent)
  563. }
  564.  
  565. WinGetNextWindow(pHEnum)
  566. {
  567.    #define ORD_WIN32GETNEXTWINDOW      756
  568.    return DynamicLink("PMWIN",ORD_WIN32GETNEXTWINDOW,BIT32,CDECL,pHEnum)
  569. }
  570.  
  571. WinEndEnumWindows(pHEnum)
  572. {
  573.    #define ORD_WIN32ENDENUMWINDOWS     737
  574.    return DynamicLink("PMWIN",ORD_WIN32ENDENUMWINDOWS,BIT32,CDECL,pHEnum)
  575. }
  576.  
  577. GetFocus()
  578. {
  579.    #define ORD_WIN32QUERYFOCUS   817
  580.    return DynamicLink("PMWIN",ORD_WIN32QUERYFOCUS,BIT32,CDECL,HWND_DESKTOP);
  581. }
  582.  
  583.