#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
#define S_SHADE 5
HB_FUNC( INITSHADOW )
{
RECT rc;
HWND hWnd = ( HWND ) hb_parnl( 1 );
HDC dc = GetDC( NULL );
HDC tdc = CreateCompatibleDC( dc );
HBITMAP map1 = CreateCompatibleBitmap( dc,1600,1200);
HGDIOBJ hOldBmp;
int w,e;
float f,g;
GetWindowRect( hWnd, &rc );
hOldBmp = SelectObject( tdc, map1 );
BitBlt( tdc, rc.left,rc.top,rc.right+S_SHADE, rc.bottom+S_SHADE,dc,rc.left,rc.top,SRCCOPY);
for( w=rc.right;w<=rc.right+S_SHADE;w++)
{
f=((float)w-rc.right)/S_SHADE;
for(e=rc.top+S_SHADE;e< rc.bottom;e++)
{
SetPixel(tdc, w,e,RGB(
GetRValue(GetPixel(tdc,w,e))/(2-f),
GetGValue(GetPixel(tdc,w,e))/(2-f),
GetBValue(GetPixel(tdc,w,e))/(2-f)));
}
}
for(e=rc.bottom;e<=rc.bottom+S_SHADE;e++)
{
f=((float)e-rc.bottom)/S_SHADE;
for(w=rc.left+S_SHADE;w<=rc.right+1;w++)
{
SetPixel(tdc,w,e,RGB(
GetRValue(GetPixel(tdc,w,e))/(2-f),
GetGValue(GetPixel(tdc,w,e))/(2-f),
GetBValue(GetPixel(tdc,w,e))/(2-f)));
}
}
for(e=rc.bottom;e<=rc.bottom+S_SHADE-2;e++)
{
f=((float)e-rc.bottom)/S_SHADE;
for(w=rc.right+2;w<=rc.right+S_SHADE-2;w++)
{
g=((float)w-rc.right+2)/(S_SHADE);
SetPixel(tdc,w,e,RGB(
GetRValue(GetPixel(tdc,w,e))/(2-(f+g)/2),
GetGValue(GetPixel(tdc,w,e))/(2-(f+g)/2),
GetBValue(GetPixel(tdc,w,e))/(2-(f+g)/2)));
}
}
BitBlt(dc, rc.left,rc.top,rc.right+S_SHADE,rc.bottom+S_SHADE,tdc,rc.left,rc.top,SRCCOPY);
SelectObject( tdc, hOldBmp );
hb_retnl( ( LONG ) map1 );
}
#pragma ENDDUMP