home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / include / GDIObject.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-11  |  1.5 KB  |  46 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   : gdiobject.h                                                         //
  12. //  Description: GDI object selection/deselection wrapper                            //
  13. //  Version    : 1.00.000, May 31, 2000                                              //
  14. //-----------------------------------------------------------------------------------//
  15.  
  16. class KGDIObject
  17. {
  18.     HGDIOBJ m_hOld;
  19.     HDC        m_hDC;
  20.  
  21. public:
  22.  
  23.     HGDIOBJ m_hObj;
  24.  
  25.     KGDIObject(HDC hDC, HGDIOBJ hObj)
  26.     {
  27.         m_hDC  = hDC;
  28.         m_hObj = hObj;
  29.         m_hOld = SelectObject(hDC, hObj);
  30.  
  31.         assert(m_hDC);
  32.         assert(m_hObj);
  33.         assert(m_hOld);
  34.     }
  35.  
  36.     ~KGDIObject()
  37.     {
  38.         HGDIOBJ h = SelectObject(m_hDC, m_hOld);
  39.     //    assert(h==m_hObj);
  40.  
  41.         DeleteObject(m_hObj);
  42.     //    assert(GetObjectType(m_hObj)==0);
  43.     }
  44. };
  45.  
  46.