//----------------------------------------------------------------------------//
METHOD SayRect( nRow, nCol, cText, nClrFore, nClrBack, nWidth, oFont, lTransparent, nAlign, nHeight ) CLASS TWindow
DEFAULT nClrFore := ::nClrText,;
nClrBack := ::nClrPane,;
oFont := ::oFont,;
lTransparent := .t.,;
nWidth := 200,;
nHeight := 20
if ValType( nClrFore ) == "C" // xBase Color string
nClrBack = nClrFore
nClrFore = nGetForeRGB( nClrFore )
nClrBack = nGetBackRGB( nClrBack )
endif
::GetDC()
nAlign := GetTextAlign( ::hDC )
nHeight := If( oFont != nil, oFont:nHeight*1.5, nHeight )
WSayRect( ::hWnd, ::hDC, nRow, nCol, cText, nClrFore, nClrBack, nWidth, ;
If( oFont != nil, oFont:hFont, 0 ), lTransparent, nAlign, nHeight )
::ReleaseDC()
return nil
*/
//----------------------------------------------------------------------------//
HB_FUNC( WSAYRECT )
{
HWND hWnd = ( HWND ) hb_parnl( 1 );
HDC hDC = ( HDC ) hb_parnl( 2 );
WORD wRow = hb_parni( 3 );
WORD wCol = hb_parni( 4 );
LPSTR szText = ( LPSTR ) hb_parc( 5 );
COLORREF clrFore = ( hb_pcount() > 5 ) ? hb_parnl( 6 ): 0;
COLORREF clrBack = ( hb_pcount() > 6 ) ? hb_parnl( 7 ): RGB( 255, 255, 255 );
WORD wRectLen = hb_parni( 8 );
HFONT hFont = ( HFONT ) hb_parnl( 9 );
BOOL bTransparent = hb_parl( 10 );
UINT uiAlign = hb_parnl( 11 ), uiOldAlign;
WORD wRectHight = hb_parni( 12 );
HFONT hOldFont;
BOOL bDestroyDC = FALSE;
RECT rct;
#ifdef UNICODE
LPWSTR pW;
#endif
COLORREF clrForeOld, clrBackOld;
if( ! hDC )
{
bDestroyDC = TRUE;
hDC = GetDC( hWnd );
}
SetTextColor( hDC, clrFore );
SetBkColor( hDC, clrBack );
if( bTransparent )
SetBkMode( hDC, TRANSPARENT );
else
SetBkMode( hDC, OPAQUE );
if( hFont )
hOldFont = ( HFONT ) SelectObject( hDC, hFont );
if( uiAlign )
uiOldAlign = SetTextAlign( hDC, uiAlign );
rct.top = wRow;
rct.bottom = rct.top + wRectHight;
rct.left = wCol;
rct.right = rct.left + wRectLen;
#ifndef UNICODE
DrawText( hDC, szText, lstrlen( szText ), &rct, DT_WORDBREAK);
#else
pW = AnsiToWide( szText );
DrawText( hDC, pW, strlen( szText ), &rct, DT_WORDBREAK);
_xfree( pW );
#endif
if( uiAlign )
SetTextAlign( hDC, uiOldAlign );
if( hFont )
SelectObject( hDC, hOldFont );
SetTextColor( hDC, clrForeOld );
SetBkColor( hDC, clrBackOld );
if( bDestroyDC )
ReleaseDC( hWnd, hDC );
}
//----------------------------------------------------------------------------//