Page 1 of 1

Manipulate Browse Scrollbars?

PostPosted: Thu Jun 08, 2006 1:48 pm
by Bill Simmeth
Is it possible to manipulate the presence of the scrollbars on WBrowse? For example, the horizontal scrollbar is always there even if there are no columns hidden. Is there a way to hide the scrollbar when it is not needed?

Similarly, the vertical scrollbar only appears when there are two or more rows on the browser. I would like to display it at all times. (I have a browser used to display an order as it is created. It starts with no records and builds as the user adds to the order. When the scrollbar appears on adding the second record, the screen layout changes which my testers find annoying.)

Thanks in advance.

PostPosted: Fri Jun 09, 2006 4:54 am
by Antonio Linares
Bill,

You may remove the horizontal scrollbar this way:
Code: Select all  Expand view
   oBrw:oHScroll:SetRange( 0, 0 )
   oBrw:oHScroll = nil

You may show the vertical scrollbar this way:
Code: Select all  Expand view
   oBrw:oVScroll:SetRange( 1, 2 )

Though it may not properly work in this case, as it does not match the number of shown records.

PostPosted: Fri Jun 09, 2006 8:17 am
by Enrico Maria Giordano
Vertical scrollbar can be automatically disabled using the style SIF_DISABLENOSCROLL. This is my changed SetScrollRange() that I'm using in my apps (but this is for FWH):

Code: Select all  Expand view
#pragma BEGINDUMP

#include <WinTen.h>
#include <Windows.h>
#include <HbApi.h>

HB_FUNC( SETSCROLLRANGE )
{
   typedef BOOL ( WINAPI * FN )( HWND, int, LPSCROLLINFO, BOOL );

   FN p = ( FN ) GetProcAddress( GetModuleHandle( "USER32" ), "SetScrollInfo" );

   SCROLLINFO si;

   si.cbSize = sizeof( si );

   if ( hb_parni( 2 ) == SB_VERT && hb_parl( 6 ) )
      si.fMask  = SIF_PAGE | SIF_RANGE | SIF_DISABLENOSCROLL;
   else
      si.fMask  = SIF_PAGE | SIF_RANGE;

   si.nPage = 1;
   si.nMin  = hb_parni( 3 );
   si.nMax  = hb_parni( 4 );

   if( p )
      hb_retl( p( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ), &si, hb_parl( 5 ) ) );
   else
      hb_retl( FALSE );
}

#pragma ENDDUMP


EMG

PostPosted: Fri Jun 09, 2006 1:59 pm
by Bill Simmeth
Antonio and Enrico, thank you for your replies and ideas.

I wound up sub-classing TWBrowse and overloaded the NEW and VSetRange methods. In NEW() I added a switch to optionally remove the WS_HSCROLL define from ::nStyle. In VSETRANGE() I set the lower limit to {1,2}. This is working fine for me.

Thanks again.

PostPosted: Fri Jun 09, 2006 9:18 pm
by Antonio Linares
Bill,

Very good :)