home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / include / mdichild.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-11  |  2.4 KB  |  82 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   : mdichild.h                                                             //
  12. //  Description: Simple MDI child window                                             //
  13. //  Version    : 1.00.000, May 31, 2000                                              //
  14. //-----------------------------------------------------------------------------------//
  15.  
  16. class KMDIChild : public KWindow
  17. {
  18. protected:
  19.     HMENU        m_hViewMenu;
  20.     int            m_nMenuID;
  21.     HINSTANCE    m_hInstance;
  22.     HBRUSH        m_hBackground;
  23.  
  24.     virtual LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  25.     {
  26.         switch( uMsg )
  27.         {
  28.             case WM_CREATE:
  29.                 m_hWnd        = hWnd;
  30.                 m_hViewMenu = LoadMenu(m_hInstance, MAKEINTRESOURCE(m_nMenuID));
  31.                 return 0;
  32.  
  33.             default:
  34.                 return CommonMDIChildProc(hWnd, uMsg, wParam, lParam, m_hViewMenu, 3);
  35.         }
  36.     }
  37.  
  38.     void GetWndClassEx(WNDCLASSEX & wc)
  39.     {
  40.         memset(& wc, 0, sizeof(wc));
  41.  
  42.         wc.cbSize         = sizeof(WNDCLASSEX);
  43.         wc.style          = CS_HREDRAW | CS_VREDRAW;
  44.         wc.lpfnWndProc    = WindowProc;
  45.         wc.cbClsExtra     = 0;
  46.         wc.cbWndExtra     = 0;       
  47.         wc.hInstance      = NULL;
  48.         wc.hIcon          = NULL;
  49.         wc.hCursor        = LoadCursor(NULL, IDC_ARROW); 
  50.         wc.hbrBackground  = m_hBackground;
  51.         wc.lpszMenuName   = NULL;
  52.         wc.lpszClassName  = NULL;
  53.         wc.hIconSm        = NULL;
  54.     }
  55.     
  56. public:
  57.  
  58.     const TCHAR * GetClassName(void) const
  59.     {
  60.         return _T("MDIChild");
  61.     }
  62.  
  63.     bool Initialize(HINSTANCE hInstance, int menuid)
  64.     {
  65.         m_nMenuID   = menuid;
  66.         m_hInstance = hInstance;
  67.  
  68.         RegisterClass(GetClassName(), hInstance);
  69.         
  70.         return true;
  71.     }
  72.  
  73.     KMDIChild(HBRUSH hBackground = NULL)
  74.     {
  75.         if ( hBackground ) 
  76.             m_hBackground = hBackground;
  77.         else
  78.             m_hBackground = (HBRUSH) (COLOR_WINDOW + 1);
  79.     }
  80.  
  81. };
  82.