HB_FUNC( BEGINPAINT ) // ( hWnd, @cPS ) --> hDC
{
PAINTSTRUCT ps;
HDC hDC = BeginPaint( ( HWND ) hb_parnl( 1 ), &ps );
hb_storclen( ( char * ) &ps, sizeof( PAINTSTRUCT ), 2 );
hb_retnl( ( LONG ) hDC );
}
Antonio Linares wrote:Enrico,
There is a working example managing cPS at FWH\samples\formdes.prg
HB_FUNC( DRAWGRID ) // hWnd, hDC, @cPS, wGridX, wGridY
{
WORD wRow, wCol;
#ifdef _WIN64
HDC hDC = ( HDC ) hb_parnll( 2 );
HWND hWnd = ( HWND ) hb_parnll( 1 );
#else
HDC hDC = ( HDC ) hb_parnl( 2 );
HWND hWnd = ( HWND ) hb_parnl( 1 );
#endif
WORD wGridX = hb_parni( 4 );
WORD wGridY = hb_parni( 5 );
RECT rc;
WORD wWidth, wHeight;
PAINTSTRUCT ps;
memcpy( &ps, hb_parc( 3 ), sizeof( PAINTSTRUCT ) );
GetWindowRect( hWnd, &rc );
wWidth = rc.right - rc.left + 1;
wHeight = rc.bottom - rc.top + 1;
for( wRow = 0; wRow <= wHeight; wRow += wGridX )
for( wCol = 0; wCol <= wWidth; wCol += wGridY )
SetPixel( hDC, wCol, wRow, 0 );
}
Antonio Linares wrote:Enrico,
Have you tried to modify DrawGrid() this way ?
HB_FUNC( DRAWGRID ) // hWnd, hDC, @cPS, wGridX, wGridY
{
WORD wRow, wCol;
#ifdef _WIN64
HDC hDC = ( HDC ) hb_parnll( 2 );
HWND hWnd = ( HWND ) hb_parnll( 1 );
#else
HDC hDC = ( HDC ) hb_parnl( 2 );
HWND hWnd = ( HWND ) hb_parnl( 1 );
#endif
WORD wGridX = hb_parni( 4 );
WORD wGridY = hb_parni( 5 );
PAINTSTRUCT ps;
memcpy( &ps, hb_parc( 3 ), sizeof( PAINTSTRUCT ) );
for( wRow = 0; wRow <= ps.rcPaint.bottom; wRow += wGridX )
for( wCol = 0; wCol <= ps.rcPaint.right; wCol += wGridY )
SetPixel( hDC, wCol, wRow, 0 );
}
Antonio Linares wrote:Enrico,
They are zero but this code seems to work fine:
Antonio Linares wrote:That is what Windows is providing us
METHOD _BeginPaint() CLASS TWindow
local cPS
if ::nPaintCount == nil
::nPaintCount = 1
else
::nPaintCount++
endif
::hDC = BeginPaint( ::hWnd, @cPS )
::cPS = cPS
return nil
if ValType( ::bPainted ) == "B"
uVal = Eval( ::bPainted, ::hDC, ::cPS, Self )
endif
Antonio Linares wrote:Enrico,
cPS is obtained here:
- Code: Select all Expand view
METHOD _BeginPaint() CLASS TWindow
local cPS
if ::nPaintCount == nil
::nPaintCount = 1
else
::nPaintCount++
endif
::hDC = BeginPaint( ::hWnd, @cPS )
::cPS = cPS
return nil
and used from bPainted:
- Code: Select all Expand view
if ValType( ::bPainted ) == "B"
uVal = Eval( ::bPainted, ::hDC, ::cPS, Self )
endif
Antonio Linares wrote:Enrico,
Here it seems fast enough, I am using a Core 2 Duo
It could be speed up using a brush instead of calling SetPixel()
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 87 guests