home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / cwindow.h < prev    next >
C/C++ Source or Header  |  1998-04-24  |  2KB  |  96 lines

  1. //+---------------------------------------------------------------------------
  2. //
  3. //  Microsoft Windows
  4. //  Copyright 1992 - 1997 Microsoft Corporation.
  5. //
  6. //  File:       cwindow.h
  7. //
  8. //  Contents:   definition of a virtual window class
  9. //
  10. //  Classes:    CHlprWindow
  11. //
  12. //  Functions:  WindowProc
  13. //
  14. //  History:    4-12-94   stevebl   Created
  15. //
  16. //----------------------------------------------------------------------------
  17.  
  18.  
  19. #ifndef __CWINDOW_H__
  20. #define __CWINDOW_H__
  21.  
  22. #include <windows.h>
  23.  
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27.  
  28. LRESULT CALLBACK WindowProc(
  29.     HWND hwnd,
  30.     UINT uMsg,
  31.     WPARAM wParam,
  32.     LPARAM lParam);
  33.  
  34. #ifdef __cplusplus
  35. }
  36.  
  37. //+---------------------------------------------------------------------------
  38. //
  39. //  Class:      CHlprWindow
  40. //
  41. //  Purpose:    virtual base class for wrapping a window
  42. //
  43. //  Interface:  Create     -- analagous to Windows' CreateWindow function
  44. //              WindowProc -- pure virtual WindowProc for the window
  45. //              ~CHlprWindow   -- destructor
  46. //              CHlprWindow    -- constructor
  47. //
  48. //  History:    4-12-94   stevebl   Created
  49. //
  50. //  Notes:      This class allows a window to be cleanly wrapped in a
  51. //              c++ class.  Specifically, it provides a way for a c++ class
  52. //              to use one of its methods as a WindowProc, giving it a "this"
  53. //              pointer and allowing it to have direct access to all of its
  54. //              private members.
  55. //
  56. //----------------------------------------------------------------------------
  57.  
  58. class CHlprWindow
  59. {
  60. public:
  61.     HWND Create(
  62.         LPCTSTR lpszClassName,
  63.         LPCTSTR lpszWindowName,
  64.         DWORD dwStyle,
  65.         int x,
  66.         int y,
  67.         int nWidth,
  68.         int nHeight,
  69.         HWND hwndParent,
  70.         HMENU hmenu,
  71.         HINSTANCE hinst);
  72.     virtual LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam) = 0;
  73.     virtual ~CHlprWindow(){};
  74.     HWND GetHwnd(void)
  75.     {
  76.         return(_hwnd);
  77.     }
  78.     CHlprWindow()
  79.     {
  80.         _hwnd = NULL;
  81.         _hInstance = NULL;
  82.     };
  83. protected:
  84. friend LRESULT CALLBACK ::WindowProc(
  85.     HWND hwnd,
  86.     UINT uMsg,
  87.     WPARAM wParam,
  88.     LPARAM lParam);
  89.     HWND _hwnd;
  90.     HINSTANCE _hInstance;
  91. };
  92.  
  93. #endif
  94.  
  95. #endif //__CWINDOW_H__
  96.