home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / cenvi29.zip / WINTOOLS.LIB < prev    next >
Text File  |  1994-04-04  |  21KB  |  559 lines

  1. // WinTools.lib - Functions for setting the state of of PM windows.  This
  2. // ver.2          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.  
  231. #include <PMdll.lib>
  232.  
  233. #define HWND_DESKTOP 1
  234.  
  235. /*******************************************************************
  236.  *********        END OF DESCRIPTION FOR WINSET.LIB        *********
  237.  *******************************************************************/
  238.  
  239.  
  240. GetWindowHandle(pWindowSpec,pFullLength)
  241. {
  242.    lHwnd = 0;  // assume failure
  243.    // Test if input is string (WindowTitle) or integer (WindowHandle)
  244.    if ( 0 == DataDimension(pWindowSpec) ) {
  245.       // Input is WindowHandle.  Verify that this handle is valid
  246.       #define ORD_WIN32ISWINDOW  772
  247.       if ( HWND_DESKTOP == pWindowSpec
  248.         || PMDynamicLink("PMWIN",ORD_WIN32ISWINDOW,BIT32,CDECL,PMInfo().hab,pWindowSpec) )
  249.          lHwnd = pWindowSpec;
  250.    } else {
  251.       // Input is WindowTitle, look through top level windows for one with this title
  252.       lTitleLen = strlen(pWindowSpec);
  253.       if ( 1 < va_arg()  &&  pFullLength )
  254.          lTitleLen++;
  255.       lEnum = WinBeginEnumWindows(HWND_DESKTOP);
  256.       while ( lChild = WinGetNextWindow(lEnum) ) {
  257.          if ( (lTitle = GetWindowTitle(lChild))  &&  !strnicmp(lTitle,pWindowSpec,lTitleLen) ) {
  258.             lHwnd = lChild;
  259.             break;
  260.          }
  261.       }
  262.       WinEndEnumWindows(lEnum);
  263.    }
  264.    return lHwnd;
  265. }
  266.  
  267.  
  268. GetWindowTitle(WindowSpec)
  269. {
  270.    if ( (_handle = GetWindowHandle(WindowSpec)) ) {
  271.       #define ORD_WIN32QUERYWINDOWTEXT 841
  272.       BLObSize(_buf,200);
  273.       if ( PMDynamicLink("PMWIN",ORD_WIN32QUERYWINDOWTEXT,BIT32,CDECL,_handle,199,_buf) ) {
  274.          strcpy(_ret,_buf);
  275.          return(_ret);
  276.       }
  277.    }
  278.    return(NULL);
  279. }
  280.  
  281. SetWindowTitle(WindowSpec,NewTitle)
  282. {
  283.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  284.       return(FALSE);
  285.    #define ORD_WIN32SETWINDOWTEXT   877
  286.    PMDynamicLink("PMWIN",ORD_WIN32SETWINDOWTEXT,BIT32,CDECL,_handle,NewTitle);
  287.    return(TRUE);
  288. }
  289.  
  290.  
  291. IsWindow(WindowSpec)
  292. {
  293.    return( GetWindowHandle(WindowSpec) );
  294. }
  295.  
  296.  
  297. #define SWP_SIZE              0x0001
  298. #define SWP_MOVE              0x0002
  299. #define SWP_ZORDER            0x0004
  300. #define SWP_SHOW              0x0008
  301. #define SWP_HIDE              0x0010
  302. #define SWP_NOREDRAW          0x0020
  303. #define SWP_NOADJUST          0x0040
  304. #define SWP_ACTIVATE          0x0080
  305. #define SWP_DEACTIVATE        0x0100
  306. #define SWP_EXTSTATECHANGE    0x0200
  307. #define SWP_MINIMIZE          0x0400
  308. #define SWP_MAXIMIZE          0x0800
  309. #define SWP_RESTORE           0x1000
  310. #define SWP_FOCUSACTIVATE     0x2000
  311. #define SWP_FOCUSDEACTIVATE   0x4000
  312.  
  313. QueryWinFlags(WindowSpec)  // return WinPos flags for this window
  314. {                          // return 0 if no good
  315.    if ( (_handle = GetWindowHandle(WindowSpec)) ) {
  316.       #define SWP_BLOB_SIZE 9 * 4
  317.       BLObSize(_swp,SWP_BLOB_SIZE);
  318.       #define ORD_WIN32QUERYWINDOWPOS  837
  319.       if ( PMDynamicLink("PMWIN",ORD_WIN32QUERYWINDOWPOS,BIT32,CDECL,_handle,_swp) )
  320.          return(BLObGet(_swp,0,UWORD32));
  321.    }
  322.    return(0);
  323. }
  324.  
  325. IsMinimized(WindowSpec)
  326. {
  327.    return( QueryWinFlags(WindowSpec) & SWP_MINIMIZE );
  328. }
  329.  
  330.  
  331. IsMaximized(WindowSpec)
  332. {
  333.    return( QueryWinFlags(WindowSpec) & SWP_MAXIMIZE );
  334. }
  335.  
  336.  
  337.  
  338. IsVisible(WindowSpec)
  339. {
  340.    #define ORD_WIN32ISWINDOWVISIBLE 775
  341.    return( (_handle = GetWindowHandle(WindowSpec))
  342.          ? PMDynamicLink("PMWIN",ORD_WIN32ISWINDOWVISIBLE,BIT32,CDECL,_handle)
  343.          : FALSE );
  344. }
  345.  
  346.  
  347. IsEnabled(WindowSpec)
  348. {
  349.    #define ORD_WIN32ISWINDOWENABLED 773
  350.    return( (_handle = GetWindowHandle(WindowSpec))
  351.          ? PMDynamicLink("PMWIN",ORD_WIN32ISWINDOWENABLED,BIT32,CDECL,_handle)
  352.          : FALSE );
  353. }
  354.  
  355.  
  356. SetWindowPos(pHandle,pBehindHandle,pColumn,pRow,pWidth,pHeight,pFlags)
  357. {
  358.    #define ORD_WIN32SETWINDOWPOS 875
  359.    PMDynamicLink("PMWIN",ORD_WIN32SETWINDOWPOS,BIT32,CDECL,
  360.                  pHandle,pBehindHandle,pColumn,pRow,pWidth,pHeight,pFlags);
  361. }
  362.  
  363.  
  364. GetWindowRect(pWindowSpec,pRectangleOrLeft,pTop,pRight,pBottom)
  365. {
  366.    if ( !(lHwnd = GetWindowHandle(pWindowSpec)) )
  367.       return(FALSE);
  368.    #define SWP_BLOB_SIZE 9 * 4
  369.    BLObSize(lSwp,SWP_BLOB_SIZE);
  370.    #define ORD_WIN32QUERYWINDOWPOS  837
  371.    if ( !DynamicLink("PMWIN",ORD_WIN32QUERYWINDOWPOS,BIT32,CDECL,lHwnd,lSwp) )
  372.       return(FALSE);
  373.    lHeight = BLObGet(lSwp,4,SWORD32);
  374.    lWidth = BLObGet(lSwp,8,SWORD32);
  375.    lBottom = BLObGet(lSwp,12,SWORD32);
  376.    lLeft = BLObGet(lSwp,16,SWORD32);
  377.    lTop = lBottom + lHeight - 1;
  378.    lRight = lLeft + lWidth - 1;
  379.    if ( 2 == va_arg() )
  380.       pRectangleOrLeft.left = lLeft, pRectangleOrLeft.right = lRight,
  381.       pRectangleOrLeft.top = lTop, pRectangleOrLeft.bottom = lBottom;
  382.    else
  383.       pRectangleOrLeft = lLeft, pRight = lRight, pTop = lTop, pBottom = lBottom;
  384.    return(TRUE);
  385. }
  386.  
  387.  
  388. SetWindowRect(pWindowSpec,pRectangleOrLeft,pTop,pRight,pBottom)
  389. {
  390.    if ( !(lHwnd = GetWindowHandle(pWindowSpec)) )
  391.       return(FALSE);
  392.    if ( 2 == va_arg() )
  393.       lLeft = pRectangleOrleft.left, lRight = pRectangleOrleft.right,
  394.       lTop = pRectangleOrleft.top, lBottom = pRectangleOrleft.bottom;
  395.    else
  396.       lLeft = pRectangleOrleft, lRight = pRight, lTop = pTop, lBottom = pBottom;
  397.    SetWindowPos(lHwnd,0,lLeft,lBottom,lRight - lLeft + 1,lTop - lBottom + 1,
  398.                 SWP_SIZE | SWP_MOVE);
  399.    return(TRUE);
  400. }
  401.  
  402.  
  403. GetScreenSize(Width,Height)
  404. {
  405.    GetSize(HWND_DESKTOP,Width,Height);
  406. }
  407.  
  408.  
  409. GetSize(WindowSpec,Width,Height)
  410. {
  411.    if ( !GetWindowRect(WindowSpec,_rect) )
  412.       return(FALSE);
  413.    Width = _rect.right - _rect.left + 1;
  414.    Height = _rect.top - _rect.bottom + 1;
  415.    return(TRUE);
  416. }
  417.  
  418.  
  419. SetSize(WindowSpec,Width,Height)
  420. {
  421.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  422.       return(FALSE);
  423.    SetWindowPos(_handle,0,0,0,Width,Height,SWP_SIZE);
  424.    return(TRUE);
  425. }
  426.  
  427.  
  428. GetPosition(WindowSpec,LeftCol,BottomRow)
  429. {
  430.    if ( !GetWindowRect(WindowSpec,_rect) )
  431.       return(FALSE);
  432.    LeftCol = _rect.left;
  433.    BottomRow = _rect.bottom;
  434.    return(TRUE);
  435. }
  436.  
  437.  
  438. SetPosition(WindowSpec,LeftCol,BottomRow)
  439. {
  440.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  441.       return(FALSE);
  442.    SetWindowPos(_handle,0,LeftCol,BottomRow,0,0,SWP_MOVE | SWP_NOADJUST);
  443.    return(TRUE);
  444. }
  445.  
  446.  
  447. ShowWindow(pWindowSpec,pCmdShow)
  448. {
  449.    if ( !(lHwnd = GetWindowHandle(pWindowSpec)) )
  450.       return(FALSE);
  451.    _active = 0;
  452.    switch( pCmdShow ) {
  453.       case SW_HIDE:
  454.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_HIDE);
  455.          break;
  456.       case SW_SHOWNOACTIVATE:
  457.          _active = GetActiveWindow();
  458.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_SHOW);
  459.          break;
  460.       case SW_MINIMIZE:
  461.       case SW_SHOWMINNOACTIVE:
  462.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_MINIMIZE);
  463.          break;
  464.       case SW_SHOWMINIMIZED:
  465.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_MINIMIZE | SWP_ACTIVATE);
  466.          break;
  467.       case SW_SHOWMAXNOACTIVE:
  468.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_MAXIMIZE);
  469.          break;
  470.       case SW_SHOWMAXIMIZED:
  471.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_MAXIMIZE | SWP_ACTIVATE);
  472.          break;
  473.       case SW_RESTORENOACTIVE:
  474.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_RESTORE);
  475.          break;
  476.       case SW_RESTORE:
  477.       case SW_SHOWNORMAL:
  478.          SetWindowPos(lHwnd,0,0,0,0,0,SWP_RESTORE | SWP_ACTIVATE);
  479.          break;
  480.       case SW_SHOW:
  481.          SetActiveWindow(lHwnd);
  482.          break;
  483.       case SW_SHOWNA:
  484.          break;
  485.       default: return(FALSE);
  486.    }
  487.    if ( _active )
  488.       SetActiveWindow(_active);
  489.    return(TRUE);
  490. }
  491.  
  492.  
  493. GetActiveWindow()
  494. {
  495.    #define ORD_WIN32QUERYACTIVEWINDOW  799
  496.    return PMDynamicLink("PMWIN",ORD_WIN32QUERYACTIVEWINDOW,BIT32,CDECL,HWND_DESKTOP);
  497. }
  498.  
  499.  
  500. SetActiveWindow(WindowSpec)
  501. {
  502.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  503.       return(FALSE);
  504.    SetWindowPos(_handle,0,0,0,0,0,SWP_ACTIVATE);
  505.    return(TRUE);
  506. }
  507.  
  508. CloseWindow(WindowSpec)
  509. {
  510.    if ( !(lHwnd = GetWindowHandle(WindowSpec)) )
  511.       return(FALSE);
  512.    #define ORD_WIN32POSTMSG   919
  513.    #define WM_CLOSE           0x0029
  514.    DynamicLink("PMWIN",ORD_WIN32POSTMSG,BIT32,CDECL,lHwnd,WM_CLOSE,0,0);
  515.    return(TRUE);
  516. }
  517.  
  518. GetFocusChild(WindowSpec)
  519. {
  520.    if ( !(lHandle = GetWindowHandle(WindowSpec)) )
  521.       return(FALSE);
  522.    if ( lHandle == GetActiveWindow() ) {
  523.       // This is currently the active window, so just get the focus window
  524.       return GetFocus();
  525.    } else {
  526.       // This window is not currently active, so get what the active window
  527.       // used to be.
  528.       #define QWL_HWNDFOCUSSAVE           0x0018
  529.       #define ORD_WIN32QUERYWINDOWULONG   843
  530.       return PMDynamicLink("PMWIN",ORD_WIN32QUERYWINDOWULONG,BIT32,CDECL,
  531.                            lHandle,QWL_HWNDFOCUSSAVE);
  532.    }
  533. }
  534.  
  535. WinBeginEnumWindows(pHwndParent)
  536. {
  537.    #define ORD_WIN32BEGINENUMWINDOWS   702
  538.    return DynamicLink("PMWIN",ORD_WIN32BEGINENUMWINDOWS,BIT32,CDECL,pHwndParent)
  539. }
  540.  
  541. WinGetNextWindow(pHEnum)
  542. {
  543.    #define ORD_WIN32GETNEXTWINDOW      756
  544.    return DynamicLink("PMWIN",ORD_WIN32GETNEXTWINDOW,BIT32,CDECL,pHEnum)
  545. }
  546.  
  547. WinEndEnumWindows(pHEnum)
  548. {
  549.    #define ORD_WIN32ENDENUMWINDOWS     737
  550.    return DynamicLink("PMWIN",ORD_WIN32ENDENUMWINDOWS,BIT32,CDECL,pHEnum)
  551. }
  552.  
  553. GetFocus()
  554. {
  555.    #define ORD_WIN32QUERYFOCUS   817
  556.    return DynamicLink("PMWIN",ORD_WIN32QUERYFOCUS,BIT32,CDECL,HWND_DESKTOP);
  557. }
  558.  
  559.