home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 6.ddi / WEXAMPLE.ZIP / BITMAP.CPP next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.2 KB  |  47 lines

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