Manipulate Browse Scrollbars?

Post Reply
Bill Simmeth
Posts: 42
Joined: Wed Oct 26, 2005 1:20 pm
Location: Marshall, Virginia, USA
Contact:

Manipulate Browse Scrollbars?

Post 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.
Bill Simmeth
Merchant Software Corp
Marshall, Virginia USA
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Bill,

You may remove the horizontal scrollbar this way:

Code: Select all | Expand

   oBrw:oHScroll:SetRange( 0, 0 )
   oBrw:oHScroll = nil

You may show the vertical scrollbar this way:

Code: Select all | Expand

   oBrw:oVScroll:SetRange( 1, 2 )

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

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Post 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

#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
Bill Simmeth
Posts: 42
Joined: Wed Oct 26, 2005 1:20 pm
Location: Marshall, Virginia, USA
Contact:

Post 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.
Bill Simmeth
Merchant Software Corp
Marshall, Virginia USA
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Bill,

Very good :)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply