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 ) ) );
}
wbrowse.prg function nwrows returning huge no
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
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
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact: