home *** CD-ROM | disk | FTP | other *** search
/ Windoware / WINDOWARE_1_6.iso / source / cppwin10 / cwind.hpp < prev    next >
C/C++ Source or Header  |  1991-01-11  |  4KB  |  145 lines

  1. /***
  2.     CWind class header file.
  3.     Modifed WBase class from Zortech WBase class.
  4. Revisions:
  5. 10/21/90 KM Initial coding changes from original WBase class.
  6. ***/
  7.  
  8. #ifndef CWind_INC
  9. #define CWind_INC
  10.  
  11. typedef    LONG (FAR PASCAL *LFPTR)(HWND,unsigned,WORD,LONG);
  12.  
  13. class    CWind    {
  14.     public: 
  15.             // Create the Applications topmost window.
  16.         CWind(HANDLE,HANDLE);
  17.  
  18.             // Create a child window.
  19.         CWind(CWind *pParent, LPSTR lpClass, LPSTR lpCaption, DWORD dwStyle,
  20.             int x, int y, int width, int height, int Id);
  21.  
  22.             // Get the window handle for the CWind class
  23.         HANDLE GetHWnd(void) { return WhWnd; }
  24.  
  25.             // Get a DC for the window.
  26.         HDC GetWndDC(void) { return GetDC(WhWnd); }
  27.  
  28.             // Release DC for the window.
  29.         void ReleaseWndDC(HDC hDC) { ReleaseDC(WhWnd, hDC); }
  30.  
  31.             // Get windows client rectangle
  32.         void GetWndClientRect(LPRECT lpRect)
  33.             { GetClientRect(WhWnd, lpRect); }
  34.  
  35.             // Get windows rectangle
  36.         void GetWndRect(LPRECT lpRect)
  37.             { GetWindowRect(WhWnd, lpRect); }
  38.  
  39.             // Set the window's title
  40.         void SetWndText(LPSTR lpTitle) { SetWindowText(WhWnd, lpTitle); }
  41.  
  42.             // Friend function to handle windows messages. This
  43.             // function is defined in the .DEF file as exported
  44.         friend    LONG FAR PASCAL Default(HWND,
  45.                         unsigned,
  46.                         WORD,
  47.                         LONG);
  48.  
  49.             // Virtual message handler for the Window.
  50.         virtual LONG FAR PASCAL Go( HWND,
  51.                         unsigned,
  52.                         WORD,
  53.                         LONG);
  54.  
  55.             // Show the window
  56.         void Show(void)
  57.             { ShowWindow(WhWnd, TRUE); }
  58.  
  59.             // Hide the window
  60.         void Hide(void)
  61.             { ShowWindow(WhWnd, FALSE); }
  62.  
  63.             // Move the window
  64.         void Move(int x, int y, int width, int height, BOOL bRepaint)
  65.             { MoveWindow(WhWnd, x, y, width, height, bRepaint); }
  66.  
  67.             // Center the window
  68.         void Center(void);
  69.  
  70.             // Update all menus. Called before Windows drops menu selected
  71.         virtual void UpdateMenus(void) { }
  72.  
  73.             // Setup the DC.
  74.         virtual void SetupDC(HDC hDC) { }
  75.  
  76.         virtual LONG DoDefault(unsigned Message, WORD wParam, LONG lParam)
  77.                 { return CallWindowProc(DefaultHandler, WhWnd, Message, wParam, lParam); }
  78.  
  79.         virtual LONG DoCommand(WORD wMenuId, LONG lParam)
  80.                 {  return DoDefault(WM_COMMAND, wMenuId, lParam);  }
  81.  
  82.         virtual LONG DoCreate(LPCREATESTRUCT lpCreate)
  83.                 {  return DoDefault(WM_CREATE, 0, 0l);    }
  84.  
  85.         virtual LONG DoDestroy(void)
  86.                 { PostQuitMessage(0); return 0l; }
  87.  
  88.         virtual LONG DoKillFocus(HWND hNewWnd)
  89.                 { return DoDefault(WM_KILLFOCUS, (WORD)hNewWnd, 0l); }
  90.  
  91.         virtual LONG DoPaint(void)
  92.                 { return DoDefault(WM_PAINT, 0, 0l); }
  93.  
  94.         virtual LONG DoSetFocus(HWND hOldWnd)
  95.                 { return DoDefault(WM_SETFOCUS, (WORD)hOldWnd, 0l); }
  96.  
  97.         virtual LONG DoSize(WORD wCmd, LPPOINT lpPoint)
  98.                 { return DoDefault(WM_SIZE, wCmd, MAKELONG(lpPoint->x, lpPoint->y)); }
  99.  
  100.         virtual LONG DoSysCommand(WORD wCmd, LPPOINT lpPoint)
  101.                 { return DoDefault(WM_SYSCOMMAND, wCmd, MAKELONG(lpPoint->x, lpPoint->y)); }
  102.  
  103.         virtual LONG DoMouseDown(unsigned Message, WORD wParam, LPPOINT lpPoint)
  104.                 { return DoDefault(Message, wParam, MAKELONG(lpPoint->x, lpPoint->y)); }
  105.  
  106.         virtual LONG DoMouseUp(unsigned Message, WORD wParam, LPPOINT lpPoint)
  107.                 { return DoDefault(Message, wParam, MAKELONG(lpPoint->x, lpPoint->y)); }
  108.  
  109.         virtual LONG DoMouseMove(WORD wParam, LPPOINT lpPoint)
  110.                 { return DoDefault(WM_MOUSEMOVE, wParam, MAKELONG(lpPoint->x, lpPoint->y)); }
  111.  
  112.     private :
  113.             // can only be called once.
  114.         BOOL    Register(HANDLE);
  115.  
  116.     protected :         // for later inheritance
  117.         static HANDLE    WhInstance;     // shared by all instances
  118.         static BOOL     WhRegistered;    // registered ?
  119.         static HANDLE    WhPrev;         // previous instance
  120.  
  121.         static short    xScreenSize;    // in pixels
  122.         static short    yScreenSize;    // as above
  123.  
  124.         HWND            WhWnd;        // handle to window
  125.         PAINTSTRUCT     ps;         // these are required
  126.         TEXTMETRIC        tm;         // by most Windows
  127.         HDC             hDC;        // instances
  128.  
  129.         FARPROC         DefaultHandler; // default callback
  130.         FARPROC         NewHandler;     // user callback
  131.  
  132.         CWind            *pParent;        // Parent window class if this is 
  133.                                         // child window.
  134.  
  135.             // Constructor for non-topmost window.
  136.         CWind() {}
  137.  
  138.             // virtual destructor
  139.         virtual ~CWind() {}
  140.  
  141.             // set a new callback
  142.         void SetCallBack(LFPTR);
  143. };
  144. #endif
  145.