🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: fj.lang.visualbasic
2 messages
2 total messages Started by carlwward Fri, 08 Dec 2000 12:08
A Scrollable Graphics Viewport - Problem/Question
#17
Author: carlwward
Date: Fri, 08 Dec 2000 12:08
64 lines
3508 bytes
Hi all,

I got the following code out of the MSDN Library Visual Basic Studio 6.0
documentation file.  It supposedly is an example of how to use Scroll Bar
Controls for Creating a Scrollable Graphics Viewport.  But it doesn't work.
Here's the problem.

The graphic is in fact displayed in the Picture2 control box. Picture1
control box displays space for the horizontal scroll bar control and for the
vertical scroll bar control, but the scroll bars are actually not displayed
in that space, if anywhere.

Can someone tell me what's wrong?  Could it be that the version of Visual
Basic that I have is not completely compatible with Win98, Extended Edition?

Would sure appreciate some help here and thanks in advance.

Carl Ward

Private Sub Form_Load()
   ' Set ScaleMode to pixels.
   Form1.ScaleMode = vbPixels
   Picture1.ScaleMode = vbPixels
   ' Autosize is set to True so that the boundaries of
   ' Picture2 are expanded to the size of the actual
   ' bitmap.
   Picture2.AutoSize = True
   ' Set the BorderStyle of each picture box to None.
   Picture1.BorderStyle = 0
   Picture2.BorderStyle = 0
   ' Load the bitmap.
   Picture2.Picture = _
   LoadPicture("c:\Windows\Winlogo.bmp")
   ' Initialize location of both pictures.
   Picture1.Move 0, 0, ScaleWidth - VScroll1.Width, _
   ScaleHeight - HScroll1.Height
   Picture2.Move 0, 0
   ' Position the horizontal scroll bar.
   HScroll1.Top = Picture1.Height
   HScroll1.Left = 0
   HScroll1.Width = Picture1.Width
   ' Position the vertical scroll bar.
   VScroll1.Top = 0
   VScroll1.Left = Picture1.Width
   VScroll1.Height = Picture1.Height
   ' Set the Max property for the scroll bars.
   HScroll1.Max = Picture2.Width - Picture1.Width
   VScroll1.Max = Picture2.Height - Picture1.Height
   ' Determine if the child picture will fill up the
   ' screen.
   ' If so, there is no need to use scroll bars.
   VScroll1.Visible = (Picture1.Height < _
   Picture2.Height)
   HScroll1.Visible = (Picture1.Width < _
   Picture2.Width)
End Sub

Private Sub HScroll1_Change()
   Picture2.Left = -HScroll1.Value
End Sub

Private Sub VScroll1_Change()
   Picture2.Top = -VScroll1.Value
End Sub
Re: A Scrollable Graphics Viewport - Problem/Question
#18
Author: carlwward
Date: Fri, 08 Dec 2000 13:21
81 lines
4064 bytes
I should have added that I started by creating a new project and then
drawing two picture boxes (#2 inside of #1), a horizontal scroll bar (inside
of picture box #1), and a vertical scroll bar (also inside of picture box
#1),  on the form.

Carl Ward

"carlwward" <carlwward@home.com> wrote in message
news:bb4Y5.37028$g6.16365308@news1.elmhst1.il.home.com...
> Hi all,
>
> I got the following code out of the MSDN Library Visual Basic Studio 6.0
> documentation file.  It supposedly is an example of how to use Scroll Bar
> Controls for Creating a Scrollable Graphics Viewport.  But it doesn't
work.
> Here's the problem.
>
> The graphic is in fact displayed in the Picture2 control box. Picture1
> control box displays space for the horizontal scroll bar control and for
the
> vertical scroll bar control, but the scroll bars are actually not
displayed
> in that space, if anywhere.
>
> Can someone tell me what's wrong?  Could it be that the version of Visual
> Basic that I have is not completely compatible with Win98, Extended
Edition?
>
> Would sure appreciate some help here and thanks in advance.
>
> Carl Ward
>
> Private Sub Form_Load()
>    ' Set ScaleMode to pixels.
>    Form1.ScaleMode = vbPixels
>    Picture1.ScaleMode = vbPixels
>    ' Autosize is set to True so that the boundaries of
>    ' Picture2 are expanded to the size of the actual
>    ' bitmap.
>    Picture2.AutoSize = True
>    ' Set the BorderStyle of each picture box to None.
>    Picture1.BorderStyle = 0
>    Picture2.BorderStyle = 0
>    ' Load the bitmap.
>    Picture2.Picture = _
>    LoadPicture("c:\Windows\Winlogo.bmp")
>    ' Initialize location of both pictures.
>    Picture1.Move 0, 0, ScaleWidth - VScroll1.Width, _
>    ScaleHeight - HScroll1.Height
>    Picture2.Move 0, 0
>    ' Position the horizontal scroll bar.
>    HScroll1.Top = Picture1.Height
>    HScroll1.Left = 0
>    HScroll1.Width = Picture1.Width
>    ' Position the vertical scroll bar.
>    VScroll1.Top = 0
>    VScroll1.Left = Picture1.Width
>    VScroll1.Height = Picture1.Height
>    ' Set the Max property for the scroll bars.
>    HScroll1.Max = Picture2.Width - Picture1.Width
>    VScroll1.Max = Picture2.Height - Picture1.Height
>    ' Determine if the child picture will fill up the
>    ' screen.
>    ' If so, there is no need to use scroll bars.
>    VScroll1.Visible = (Picture1.Height < _
>    Picture2.Height)
>    HScroll1.Visible = (Picture1.Width < _
>    Picture2.Width)
> End Sub
>
> Private Sub HScroll1_Change()
>    Picture2.Left = -HScroll1.Value
> End Sub
>
> Private Sub VScroll1_Change()
>    Picture2.Top = -VScroll1.Value
> End Sub
>
>
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads