It seems that cPS parameter provided to bPainted doesn't have the expected data. Can you confirm this? If yes, any fix?
EMG
It seems that cPS parameter provided to bPainted doesn't have the expected data. Can you confirm this? If yes, any fix?
EMG
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 );
}Enrico,
There is a working example managing cPS at FWH\samples\formdes.prg
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 ?
Enrico,
ps.rcPaint.bottom and ps.rcPaint.right are non zero, so they seem valid.
Going to check top and left...
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:
That is what Windows is providing us ![]()
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 )
endifAntonio Linares wrote:Enrico,
cPS is obtained here:
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:
if ValType( ::bPainted ) == "B" uVal = Eval( ::bPainted, ::hDC, ::cPS, Self ) endif
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()
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()