How to print filled rectangle?
Posted: Wed Aug 26, 2009 8:31 am
Hi guys (sorry, no women found
)
I wanna print black rectangle. How Can I do that?
I wanna print black rectangle. How Can I do that?
Exclusive forum for HMG, a Free / Open Source xBase WIN32/64 Bits / GUI Development System
http://mail.hmgforum.com/
Code: Select all
HB_FUNC ( _HMG_PRINTER_C_RECTANGLE )
{
// 1: hDC
// 2: y
// 3: x
// 4: toy
// 5: tox
// 6: width
// 7: R Color
// 8: G Color
// 9: B Color
// 10: lWindth
// 11: lColor
int r ;
int g ;
int b ;
int x = hb_parni(3) ;
int y = hb_parni(2) ;
int tox = hb_parni(5) ;
int toy = hb_parni(4) ;
int width ;
HDC hdcPrint = (HDC) hb_parnl(1) ;
HGDIOBJ hgdiobj;
// HPEN hpen;
HBRUSH hbrush;
if ( hdcPrint != 0 )
{
// Width
if ( hb_parl(10) )
{
width = hb_parni(6) ;
}
else
{
width = 1 * 10000 / 254 ;
}
// Color
if ( hb_parl(11) )
{
r = hb_parni(7) ;
g = hb_parni(8) ;
b = hb_parni(9) ;
}
else
{
r = 0 ;
g = 0 ;
b = 0 ;
}
hbrush = CreateSolidBrush((COLORREF) RGB((int) r,(int) g,(int) b));
// hpen = CreatePen( (int) PS_SOLID, ( width * GetDeviceCaps ( hdcPrint , LOGPIXELSX ) / 1000 ), (COLORREF) RGB( r , g , b ) );
hgdiobj = SelectObject( (HDC) hdcPrint , hbrush );
Rectangle( (HDC) hdcPrint ,
( x * GetDeviceCaps ( hdcPrint , LOGPIXELSX ) / 1000 ) - GetDeviceCaps ( hdcPrint , PHYSICALOFFSETX ) ,
( y * GetDeviceCaps ( hdcPrint , LOGPIXELSY ) / 1000 ) - GetDeviceCaps ( hdcPrint , PHYSICALOFFSETY ) ,
( tox * GetDeviceCaps ( hdcPrint , LOGPIXELSX ) / 1000 ) - GetDeviceCaps ( hdcPrint , PHYSICALOFFSETX ) ,
( toy * GetDeviceCaps ( hdcPrint , LOGPIXELSY ) / 1000 ) - GetDeviceCaps ( hdcPrint , PHYSICALOFFSETY )
);
SelectObject( (HDC) hdcPrint , (HGDIOBJ) hgdiobj );
DeleteObject( hbrush );
// DeleteObject( hpen );
}
}
No Swapan, It is not a correction.swapan wrote:Great Rathi! Hope you'll note down this "would be correction" for future version.