wbrowse.prg function nwrows returning huge no

wbrowse.prg function nwrows returning huge no

Postby peterk » Wed Nov 15, 2006 10:18 am

Hi Antonio

I have a situation where wbrowse.prg method nRowCount is returning 53000 rows! This causes one of my browses on a dbf (which has +- 160,000 records in it) to take ages to open.

nRowCount calls nwrows which calls GetWindowRows (extracted below)

nRowCount should obviously never return more than the no of rows a browse could theoretically display with its font - say 100

It only happens on the 1st call to nRowCount (in our case from upstable), which causes UpStable to skip through 53000 records. Thereafter it returns the correct no of rows (39)

The font object in Wbrowse has a valid handle and seems fine.

Can you comment on what might be causing this ?

Thanks
Peter



*********************************
WORD GetWindowRows( HWND hWnd, HDC hDC, HFONT hFont )
{
TEXTMETRIC tm;
RECT rct;
WORD wRows;
BOOL bDCDestroy = FALSE;
HFONT hOldFont;

if( ! hDC )
{
bDCDestroy = TRUE;
hDC = GetDC( hWnd );
}

if( hFont )
hOldFont = ( HFONT ) SelectObject( hDC, hFont );

GetTextMetrics( hDC, &tm );
tm.tmHeight += 1;

GetClientRect( hWnd, &rct );
wRows = ( rct.bottom - rct.top ) / tm.tmHeight;

if( hFont )
SelectObject( hDC, hOldFont );

if( bDCDestroy )
ReleaseDC( hWnd, hDC );

return wRows;
}

//----------------------------------------------------------------------------//

CLIPPER NWROWS( PARAMS ) // hWnd, hDC, hFont
{
_retni( GetWindowRows( ( HWND ) _parnl( 1 ), ( HDC ) _parnl( 2 ),
( HFONT ) _parnl( 3 ) ) );
}
Peter
peterk
 
Posts: 47
Joined: Thu Jul 13, 2006 2:39 pm

Postby Antonio Linares » Wed Nov 15, 2006 12:10 pm

Peter,

Are you calling the UpStable method before the browse is created by Windows ? (oBrw:hWnd != 0 )

Is it placed on a dialog ? If so, please call UpStable from here:

ACTIVATE DIALOG oDlg ON INIT oBrw:UpStable()
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby peterk » Wed Nov 15, 2006 1:24 pm

Antonio

Yes you are correct! I am calling upstable while the Brw ::hWnd is 0

May I suggest you change wBrowse nRowCount method as follows to prevent other users wasting time on the same issue

METHOD nRowCount() INLINE ;
if(::hWnd > 0, nWRows( ::hWnd, 0, If( ::oFont != nil, ::oFont:hFont, 0 ) ) - 1, 0)

Thanks for the assistance
Peter
Peter
peterk
 
Posts: 47
Joined: Thu Jul 13, 2006 2:39 pm

Postby Antonio Linares » Wed Nov 15, 2006 1:29 pm

Peter,

Changed, thanks.

Please use ::hWnd != 0 instead of ::hWnd > 0
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Otto, Silvio.Falconi and 54 guests