home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dho.zip / DHO / SRC / SOURCE.ZIP / winbase.cc < prev    next >
C/C++ Source or Header  |  1995-08-27  |  4KB  |  197 lines

  1. /****************************************/
  2. /*    Developer Helper Object Set       */
  3. /*  (C) 1994-95 Thomas E. Bednarz, Jr.  */
  4. /*     All rights reserved              */
  5. /***************************************/
  6.  
  7. /* $Id: winbase.cc 1.8 1995/08/21 05:26:50 teb Exp $ */
  8.  
  9.  
  10. #include "winbase.h"
  11. #include "applicat.h"
  12.  
  13. //-------------------------------------------------------------------
  14. //  getScreenPS
  15. HPS TWinBase::getScreenPS()
  16. {
  17.    return WinGetPS( getHWND() );
  18. }
  19.  
  20. //-------------------------------------------------------------------
  21. //  TWinBase
  22. TWinBase::TWinBase(ULONG id)
  23. {
  24.    fResource = id;
  25.    hwnd = (HWND)NULL;
  26. }
  27.  
  28. //-------------------------------------------------------------------
  29. //  ~TWinBase
  30. TWinBase::~TWinBase(void)
  31. {
  32.    if (hwnd!=(HWND)NULL)
  33.       WinDestroyWindow(hwnd);
  34. }
  35.  
  36. //-------------------------------------------------------------------
  37. //   getClassName
  38. const char *TWinBase::getClassName(void)
  39. {
  40.    return "TWinBase";
  41. }
  42.  
  43. //-------------------------------------------------------------------
  44. //   GetFrame
  45. HWND TWinBase::getHWND(void)
  46. {
  47.    return hwnd;
  48. }
  49.  
  50. //-------------------------------------------------------------------
  51. //  doControl
  52. void TWinBase::doControl(WinMsg wm)
  53. {
  54.    
  55. }
  56.  
  57.  
  58. //-------------------------------------------------------------------
  59. //   doCommand
  60. void TWinBase::doCommand(WinMsg wm)
  61. {
  62.  
  63. }
  64.  
  65.  
  66. //-------------------------------------------------------------------
  67. //   isEnabled
  68. BOOL TWinBase::isEnabled()
  69. {
  70.    return WinIsWindowEnabled( getHWND() );
  71. }
  72.  
  73. //-------------------------------------------------------------------
  74. //   enableUpdate
  75. BOOL TWinBase::enableUpdate(BOOL enable)
  76. {
  77.    WinEnableWindowUpdate( getHWND(),enable);
  78.    return TRUE;
  79. }
  80.  
  81. //-------------------------------------------------------------------
  82. //   isVisible
  83. BOOL TWinBase::isVisible()
  84. {
  85.    return WinIsWindowVisible( getHWND() );
  86. }
  87.  
  88.  
  89. //-------------------------------------------------------------------
  90. //   setParent
  91. BOOL TWinBase::setParent(TWinBase *parent, BOOL redraw)
  92. {
  93.    BOOL res = WinSetParent( getHWND(), parent->getHWND(), redraw);
  94.    //fParent = parent;
  95.  
  96.    return res;
  97. }
  98.  
  99.  
  100. //-------------------------------------------------------------------
  101. //   setFrameTitle
  102. void TWinBase::setFrameTitle(char *title)
  103. {
  104.    HWND hwndTitlebar = WinWindowFromID(hwnd, FID_TITLEBAR);
  105.    if (hwndTitlebar)
  106.       WinSetWindowText(hwndTitlebar, (PSZ)title);
  107.  
  108. }
  109.  
  110. //-------------------------------------------------------------------
  111. //   isChild
  112. BOOL TWinBase::isChild(TWinBase *parent)
  113. {
  114.    return WinIsChild(getHWND() , parent->getHWND() );
  115. }
  116.  
  117.  
  118. //-------------------------------------------------------------------
  119. //   
  120. void TWinBase::shellSetPosition()
  121. {
  122.    SWP swp;
  123.  
  124.    WinQueryTaskSizePos(Application->getAnchorBlock(),
  125.                        0, &swp);
  126.  
  127.    setWindowPosition(swp.x, swp.y);
  128. }
  129.  
  130.  
  131.  
  132. //-------------------------------------------------------------------
  133. //   setWindowPosition
  134. void TWinBase::setWindowPosition(LONG x, LONG y)
  135. {
  136.    WinSetWindowPos(getHWND(), (HWND) NULL,  x, y, 0,0, SWP_MOVE);
  137.  
  138. }
  139.  
  140. //-------------------------------------------------------------------
  141. //   getWindowPosition
  142. void TWinBase::getWindowPosition(LONG &x, LONG &y, LONG &cx, LONG &cy)
  143. {
  144.    SWP swp;
  145.  
  146.    WinQueryWindowPos( getHWND(),&swp);
  147.    x = swp.x;
  148.    y = swp.y;
  149.    cx = swp.cx;
  150.    cy = swp.cy;
  151.  
  152. }
  153.  
  154.  
  155. //-------------------------------------------------------------------
  156. //   setWindowSize
  157. void TWinBase::setWindowSize(LONG cx, long cy)
  158. {
  159.    LONG x,y,dum1, dum2;
  160.    getWindowPosition(x,y,dum1, dum2);
  161.    WinSetWindowPos(getHWND(), (HWND)NULL, x,y,cx,cy, SWP_MOVE | SWP_SIZE);
  162. }
  163.  
  164.  
  165.  
  166. //-------------------------------------------------------------------
  167. //   hideWindow
  168. void TWinBase::hideWindow()
  169. {
  170.    WinShowWindow(getHWND(), FALSE);
  171. }
  172.  
  173.  
  174. //-------------------------------------------------------------------
  175. //   showWindow
  176. void TWinBase::showWindow()
  177. {
  178.    WinShowWindow(getHWND(), TRUE);
  179. }
  180.  
  181.  
  182. //-------------------------------------------------------------------
  183. //   Update
  184. void TWinBase::Update()
  185. {
  186.    WinUpdateWindow(getHWND());
  187. }
  188.  
  189.  
  190. //-------------------------------------------------------------------
  191. //   ForceUpdate
  192. void TWinBase::forceUpdate()
  193. {
  194.    WinInvalidateRect(hwnd, NULL, TRUE);
  195. }
  196.  
  197.