home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / dlldemo.pak / BITMAP.CPP next >
C/C++ Source or Header  |  1997-07-23  |  1KB  |  45 lines

  1. // Borland C++ - (C) Copyright 1991, 1992 by Borland International
  2. //
  3.  
  4. #define  STRICT
  5. #include <windows.h>
  6. #pragma hdrstop
  7.  
  8. #define _EXPORT _export
  9. #include "bitmap.h"
  10.  
  11. // Implementation of CompatibleDC and Bitmap classes.
  12.  
  13. class CompatibleDC
  14. {
  15.     private:
  16.         HDC hDCMem;
  17.     public:
  18.         // Create a memory device context, specify a selected object,
  19.         // and set the DC's mapping mode.
  20.         CompatibleDC( HDC hDC )
  21.         {
  22.             hDCMem = CreateCompatibleDC( hDC );
  23.             SetMapMode( hDCMem, GetMapMode( hDC ) );
  24.         }
  25.         ~CompatibleDC( void ) { DeleteDC( hDCMem ); };
  26.         HDC Get_hDCMem( void ) { return hDCMem; }
  27. };
  28.  
  29. void FAR _export Bitmap::Display( HDC hDC, int xStart, int yStart )
  30. {
  31.     POINT ptSize, ptOrigin;
  32.  
  33.     CompatibleDC MemoryDC( hDC );
  34.     HDC hDCMem = MemoryDC.Get_hDCMem();
  35.     SelectObject( hDCMem, hBitmap );
  36.  
  37.     ptSize = GetSize( hDC );
  38.     ptOrigin.x = 0;
  39.     ptOrigin.y = 0;
  40.     DPtoLP( hDCMem, &ptOrigin, 1 );
  41.  
  42.     BitBlt( hDC, xStart, yStart, ptSize.x, ptSize.y,
  43.             hDCMem, ptOrigin.x, ptOrigin.y, SRCCOPY );
  44. }
  45.