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