home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_7 / 2.ddi / WEXAMPLE.ZIP / BITMAP.CPP next >
Encoding:
C/C++ Source or Header  |  1991-02-13  |  1.2 KB  |  46 lines

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