home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / include / win.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-20  |  2.5 KB  |  86 lines

  1. #pragma once
  2.  
  3. //-----------------------------------------------------------------------------------//
  4. //              Windows Graphics Programming: Win32 GDI and DirectDraw               //
  5. //                             ISBN  0-13-086985-6                                   //
  6. //                                                                                   //
  7. //  Written            by  Yuan, Feng                             www.fengyuan.com   //
  8. //  Copyright (c) 2000 by  Hewlett-Packard Company                www.hp.com         //
  9. //  Published          by  Prentice Hall PTR, Prentice-Hall, Inc. www.phptr.com      //
  10. //                                                                                   //
  11. //  FileName   : win.h                                                                 //
  12. //  Description: Generic window class                                                //
  13. //  Version    : 1.00.000, May 31, 2000                                              //
  14. //-----------------------------------------------------------------------------------//
  15.  
  16. class KWindow
  17. {
  18. protected:
  19.  
  20.     virtual void OnDraw(HDC hDC)
  21.     {
  22.     }
  23.  
  24.     virtual void OnKeyDown(WPARAM wParam, LPARAM lParam)
  25.     {
  26.     }
  27.     
  28.     virtual LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  29.  
  30.     virtual void GetWndClassEx(WNDCLASSEX & wc);
  31.  
  32.     static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  33.    
  34.     HRESULT CommonMDIChildProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, 
  35.         HMENU hMenu, int nWindowMenu);
  36.  
  37.     HPALETTE m_hPalette;
  38.     int         m_nUpdateCount;
  39.  
  40.     virtual LRESULT OnQueryNewPalette(void);
  41.     virtual LRESULT OnPaletteChanged(HWND hWnd, WPARAM wParam);
  42.  
  43.     bool    m_bMainWindow;
  44.  
  45. public:
  46.  
  47.     HWND  m_hWnd;
  48.  
  49.     KWindow(void)
  50.     {
  51.         m_hWnd           = NULL;
  52.         m_hPalette       = NULL;
  53.         m_nUpdateCount = 0;
  54.         m_bMainWindow  = false;
  55.     }
  56.  
  57.     virtual ~KWindow(void)
  58.     {
  59.         if ( m_hPalette )
  60.         {
  61.             DeleteObject(m_hPalette);
  62.             m_hPalette = NULL;
  63.         }
  64.     }
  65.     
  66.     virtual bool CreateEx(DWORD dwExStyle, LPCTSTR lpszClass, LPCTSTR lpszName, DWORD dwStyle, 
  67.         int x, int y, int nWidth, int nHeight, HWND hParent, HMENU hMenu, HINSTANCE hInst);
  68.  
  69.     bool RegisterClass(LPCTSTR lpszClass, HINSTANCE hInst);
  70.  
  71.     virtual WPARAM MessageLoop(void);
  72.  
  73.     BOOL ShowWindow(int nCmdShow) const
  74.     {
  75.         return ::ShowWindow(m_hWnd, nCmdShow);
  76.     }
  77.  
  78.     BOOL UpdateWindow(void) const
  79.     {
  80.         return ::UpdateWindow(m_hWnd);
  81.     }
  82. };
  83.  
  84.  
  85. int MyMessageBox(HWND hWnd, const TCHAR * text, const TCHAR * caption, DWORD style, int iconid);
  86.