void GradientFill( HDC hDC, RECT* rct, COLORREF crStart, COLORREF crEnd, int bVertical )
{
int nSegments = 100;
COLORREF cr;
int nR = GetRValue(crStart);
int nG = GetGValue(crStart);
int nB = GetBValue(crStart);
int neB = GetBValue(crEnd);
int neG = GetGValue(crEnd);
int neR = GetRValue(crEnd);
int nDiffR = (neR - nR);
int nDiffG = (neG - nG);
int nDiffB = (neB - nB);
int ndR ;
int ndG ;
int ndB ;
int nCX ;
int nCY ;
int nTop = rct->top;
int nBottom = rct->bottom;
int nLeft = rct->left;
int nRight = rct->right;
HBRUSH hBrush;
RECT rc;
int i;
if( !bVertical )
{
if( nSegments > ( rct->right - rct->left ) )
{
nSegments = ( rct->right - rct->left );
}
}
else
{
if( nSegments > ( rct->bottom - rct->top ) )
{
nSegments = ( rct->bottom - rct->top );
}
}
ndR = 256 * (nDiffR) / (max(nSegments,1));
ndG = 256 * (nDiffG) / (max(nSegments,1));
ndB = 256 * (nDiffB) / (max(nSegments,1));
nCX = (rct->right-rct->left) / max(nSegments,1);
nCY = (rct->bottom-rct->top) / max(nSegments,1);
nR *= 256;
nG *= 256;
nB *= 256;
for (i = 0; i < nSegments; i++, nR += ndR, nG += ndG, nB += ndB)
{
if(i == (nSegments - 1))
{
nRight = rct->right;
nBottom = rct->bottom;
}
else
{
nBottom = nTop + nCY;
nRight = nLeft + nCX;
}
cr = RGB(nR / 256, nG / 256, nB / 256);
{
hBrush = CreateSolidBrush( cr );
if( bVertical )
{
rc.top = nTop;
rc.left = rct->left;
rc.bottom = nBottom + 1;
rc.right = rct->right;
}
else
{
rc.top = rct->top;
rc.left = nLeft;
rc.bottom = rct->bottom;
rc.right = nRight+1;
}
FillRect(hDC, &rc, hBrush );
DeleteObject( hBrush );
}
nLeft = nRight;
nTop = nBottom;
}
}
HB_FUNC( DEGRADA )
{
RECT rct;
rct.top = hb_parni( 2, 1 );
rct.left = hb_parni( 2, 2 );
rct.bottom = hb_parni( 2, 3 );
rct.right = hb_parni( 2, 4 );
GradientFill( ( HDC ) hb_parnl( 1 ) , &rct, hb_parnl( 3 ), hb_parnl( 4 ), hb_parl(5) );
}
local lVertical := .t.
Degrada( hDC, { 10, 10, 200, 200}, CLR_WHITE, CLR_BLUE, lVertical )
#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
.... la función c
#pragma ENDDUMP
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 30 guests