VB6 Scroll Form Scroll bar size

tlengnick
tlengnick used Ask the Experts™
on
I have made part of my form scrollable by placing a picturebox on a form, then placing an MSFlexgrid on the picturebox (I guess pictureboxes have a scroll bar by default).

Anyway, this may sound petty, but the scroll bar is way to small for the size of the picturebox. In other words, there is only about 2 inches of flexgrid that is "off screen" and subsequently revealed by scrolling down with the scrollbar.

However, the size of the "little grey rectangle" part of the scroll bar (the thing you "grab" and move to scroll the page), takes only about 5% of the scroll area (whereas it should take up about 90% of it, considering there is almost nothing to scroll).

Any chance I can get that thing to act more like regular scroll bars do?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010

Commented:
It's MSFlexgrid that has scrollbars.
 You do not need the picture box.
 As for the size of scroll thumb, it's designed like that. There is no way to change it.
ScrollBar Width is a system setting.
It can be retrieved by using API GetSystemMetrics

   Private Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
   Const SM_CXVSCROLL As Long = 2
   Const SM_CYVSCROLL As Long = 20

The width is usually 17 pixels.

To change this:

Windows XP:
   http://www.computertim.com/howto/article.php?topic=windows&idn=76

Windows 7:
   http://social.answers.microsoft.com/Forums/en-US/w7desktop/thread/b45bf22b-4882-45e1-9b3c-5051da0dc631

As pointed out above there is no need for a PictureBox. If you do use a Picture Box and do not resize the MSFlexGrid control correctly the scrollbar could indeed be clipped.


Commented:
The normal to do this - if I remember correctly - is to put a scrollbar control on the form itself.  Then, respond to events from that by (block) moving your other controls as desired.
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Author

Commented:
danaseaman,

I haven't tried what you've suggested yet, but it looks like you're showing me how to change the WIDTH of the scrollbar. What I'm having issue with is the amount of "scroll thumb" as Zhaoli called it (I didn't know the name - it's the part you grab with the mouse and move up and down to scroll the page) that occupies the scrollbar, depending on how many "pages" the document is.

For example, on this Expert's Exchange "Open Question" page in which I am typing, I see a scrolbar on the right of the screen. The scroll thumb height is about 1/3 the length of the entire "scroll area." This gives me an idea that I only have about 3 more of "this screen's worth" of scrolling to do before I get to the top. If the scroll thumb were currently very small, I would assume that I have A LONG WAY TO GO before I scroll all the way to the top of this webpage.

The issue is that, although my FlexGrid is only 60 rows long, the scroll thumb is very short, occupying only about 5% of the scroll area. This is misleading and annoying, because when you grab it and move it, it automatically "jumps" to the bottom of the scroll area because only a small percentage of the screen was not visible...

Peetm,

Are you suggesting to kind of "build my own scroll bar", but putting a scrollbar control on the form, then write code that sets the VTOP property of all the components as the scroll thumb is moved up and down?
Commented:


>>Are you suggesting to kind of "build my own scroll bar", but putting a scrollbar control on the form, then write code that sets the VTOP property of all the components as the scroll thumb is moved up and down?

'fraid so!  It's actually one of the best ways to control what's going on imho.  And, when you block-move over a refresh cycle, it looks quite neat.

BTW, I'm *not* in favour of scrolling forms normally. I'm usually of the opinion that if controls need to be scrolled, that there's too many of them, and that one ought to use modal dialogs instead.  Still, I;m sure there are any number of exceptions!
Top Expert 2010

Commented:
Have you tried using ListView control? It's similar to Flexgrid, with fewer features, but it has normal scroll bars, to say the least.

Author

Commented:
Peetm,

The reason I'm scrolling the form is b/c I'm printing that form on an 8.5x11" piece of paper (the form mimics a preprinted survey that we use at work that I am automating. I don't know how else to show the actual form on the screen in a WYSIWYG format... since it's so big, I have to scroll.

Zhaolai - I'll take a look at that listView control and do some research as to what functionality I'd be giving up.

Thanks all...
There is indeed strange behavior with MSFlexGrid Scrollbars.
With 60 Rows here is what I get when querying the ScrollBar with API.

When clicking on Row 0 I get:

tsi.nMin       1
tsi.nMax       22
tsi.nPage      0
tsi.nPos       1
tsi.nTrackPos  1

When clicking on Row 59 I get:

tsi.nMin       1
tsi.nMax       22
tsi.nPage      0
tsi.nPos       22
tsi.nTrackPos  22

I didn't query ListView but the "ScrollThumb" size appears correct.


Author

Commented:
danaseaman,

Your answer is beyond my skill set. I'm not sure what the tsi.nPos/TrackPos 1-22 tells me. However, I still don't think I've made clear what is bothering me about the scroll thumb. In every application that I use (including the VB6 authoring environment itself and this webpage), the VERTICAL HEIGHT of the scroll thumb correlates to the "amount of scrolling" it needs to do to get to the top/bottom of the current window.

For example, if you look at your screen right now, you will see a scroll bar on the right-hand side of it. It has a height in relation to the entire "vertical scroll area" in which it sits. My scroll thumb currently is about 1/6th the entire vertical scroll area. If I click in the blank area of the scroll field about 6 times, it pulls the scroll thumb all the way to the top of the page, moving it approximately 1/6th of the way with each click.

In essence, the vertical height of the scroll thumb tells me about how "far away" the top of the current window is.

The MSFlexgrid's scroll thumb appears to be approximately 1/20th of the vertical height of the scroll area. However, instead of needing 20 clicks to pull it to the top, it only takes 3. Therefore, I want to make the flexgrid's scroll thumb to behave like the other scroll thumbs (including the one in this little window I'm typing in... it's about 1/2 the vertical height of the scroll area... with 1 click, I'm at the top of this window).

Sorry for the lengthy explanation for something that may seem trivial... I just want my program to act like software that everyone is used to, and I think the behavior of the flexgrid scrollbar is aberrant.

Author

Commented:
Zhaolai,

I've looked up several threads to learn the difference between ListView and FlexGrid and have gotten mostly crap...

Do you have a link I can read up on the difference between the two?

Author

Commented:
Guess I need to let this one go... thanks for the feedback and attempts, gents... allocating points for effort...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial