#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>

// Thanks to Mr. Petzold !

//----------------------------------------------------------------------------//

CLIPPER MENUBITMAP()
{
   HBITMAP hBitmap1 = ( HBITMAP ) _parni( 1 );
   BITMAP  bm1, bm2;
   HBITMAP hBitmap2;
   HDC hdc, hdcMem1, hdcMem2;
   TEXTMETRIC tm;

   hdc = GetDC( GetActiveWindow() );
   GetTextMetrics( hdc, &tm );
   hdcMem1 = CreateCompatibleDC( hdc );
   hdcMem2 = CreateCompatibleDC( hdc );
   DeleteDC( hdc );

   GetObject( hBitmap1, sizeof( BITMAP ), ( LPSTR ) &bm1 );

   bm2 = bm1;
   bm2.bmWidth      = ( tm.tmAveCharWidth * bm2.bmWidth )  / 4;
   bm2.bmHeight     = ( tm.tmHeight       * bm2.bmHeight ) / 8;
   bm2.bmWidthBytes = ( ( bm2.bmWidth + 15 ) / 16 ) * 2;

   hBitmap2 = CreateBitmapIndirect( &bm2 );

   SelectObject( hdcMem1, hBitmap1 );
   SelectObject( hdcMem2, hBitmap2 );

   StretchBlt( hdcMem2, 0, 0, bm2.bmWidth, bm2.bmHeight,
               hdcMem1, 0, 0, bm1.bmWidth, bm1.bmHeight, SRCCOPY );

   DeleteDC( hdcMem1 );
   DeleteDC( hdcMem2 );
   DeleteObject( hBitmap1 );

   _retnl( hBitmap2 );
}

//----------------------------------------------------------------------------//
