sujiforu
Aug 30th, 2001, 06:08 AM
Iam using the two picture box phenomenon to scroll my conterols inside the inner picture box.
In case you dont have an idea about this.
This is the way Iam doing it.
I have 2 pic boxes -
inner and outer.
There are huge number of controls not displayable in a single screen.
So i move the inner picture box inside the outer one to display all controls.
Now the problem i have is ,
while scrolling, Iam exceeding both the scrollbar's maximum property and the inner picture boxes' left property.
I will send the code along.
The problem is quite a serious one ,
please help me.Urgent.
Dim got_wid As Single
Dim got_hgt As Single
Dim need_wid As Single
Dim need_hgt As Single
Dim need_hbar As Boolean
Dim need_vbar As Boolean
If WindowState = vbMinimized Then Exit Sub
need_wid = InnerPict.Width + (OuterPict.Width - OuterPict.ScaleWidth)
need_hgt = InnerPict.height + (OuterPict.height - OuterPict.ScaleHeight)
got_wid = ScaleWidth
got_hgt = ScaleHeight
' See which scroll bars we need.
need_hbar = (need_wid > got_wid)
'If need_hbar Then got_hgt = got_hgt - HBar.height
If need_hbar Then got_hgt = got_hgt
need_vbar = (need_hgt > got_hgt)
If need_vbar Then
got_wid = got_wid - VBar.Width
If Not need_hbar Then
need_hbar = (need_wid > got_wid)
'If need_hbar Then got_hgt = got_hgt - HBar.height
If need_hbar Then got_hgt = got_hgt
End If
End If
OuterPict.Move 0, 0, got_wid, got_hgt
If need_hbar Then
HBar.Move 0, got_hgt - HBar.height, got_wid
HBar.Visible = True
Else
HBar.Visible = False
End If
If need_vbar Then
VBar.Move got_wid, 0, VBar.Width, got_hgt
'VBar.Move got_wid, 0, VBar.Width, got_hgt
VBar.Visible = True
Else
VBar.Visible = False
End If
findExtremePosition
If rightMost < OuterPict.Width Then
rightMost = OuterPict.Width
End If
If BottomMost < OuterPict.height Then
BottomMost = OuterPict.height
End If
InnerPict.Width = rightMost + 1000
InnerPict.height = BottomMost + 1000
SetScrollBars
Code for method "findExtemePosition"
Dim CTL As Control
TopMost = 0
BottomMost = 0
leftMost = 0
rightMost = 0
For Each CTL In Me
If TypeOf CTL Is PictureBox Then
If CTL.Top < TopMost Then
TopMost = CTL.Top
End If
If CTL.Top > BottomMost Then
BottomMost = CTL.Top + CTL.height
End If
If CTL.Left < leftMost Then
TopMost = CTL.Left
End If
If CTL.Left > rightMost Then
rightMost = CTL.Left + CTL.Width
'MsgBox Ctl.Caption
End If
End If
Next
Code for setScrollBars
VBar.Min = 0
VBar.Max = OuterPict.ScaleHeight - InnerPict.height
VBar.LargeChange = OuterPict.ScaleHeight
VBar.SmallChange = OuterPict.ScaleHeight / 5
HBar.Min = 0
HBar.LargeChange = OuterPict.ScaleWidth
HBar.SmallChange = OuterPict.ScaleWidth / 5
HBar.Max = OuterPict.ScaleWidth - InnerPict.Width
The max value exceed s -32768
and throws an overflow error,
when not even half my controls are seen.
Thanking in advance,
Sujith.K
In case you dont have an idea about this.
This is the way Iam doing it.
I have 2 pic boxes -
inner and outer.
There are huge number of controls not displayable in a single screen.
So i move the inner picture box inside the outer one to display all controls.
Now the problem i have is ,
while scrolling, Iam exceeding both the scrollbar's maximum property and the inner picture boxes' left property.
I will send the code along.
The problem is quite a serious one ,
please help me.Urgent.
Dim got_wid As Single
Dim got_hgt As Single
Dim need_wid As Single
Dim need_hgt As Single
Dim need_hbar As Boolean
Dim need_vbar As Boolean
If WindowState = vbMinimized Then Exit Sub
need_wid = InnerPict.Width + (OuterPict.Width - OuterPict.ScaleWidth)
need_hgt = InnerPict.height + (OuterPict.height - OuterPict.ScaleHeight)
got_wid = ScaleWidth
got_hgt = ScaleHeight
' See which scroll bars we need.
need_hbar = (need_wid > got_wid)
'If need_hbar Then got_hgt = got_hgt - HBar.height
If need_hbar Then got_hgt = got_hgt
need_vbar = (need_hgt > got_hgt)
If need_vbar Then
got_wid = got_wid - VBar.Width
If Not need_hbar Then
need_hbar = (need_wid > got_wid)
'If need_hbar Then got_hgt = got_hgt - HBar.height
If need_hbar Then got_hgt = got_hgt
End If
End If
OuterPict.Move 0, 0, got_wid, got_hgt
If need_hbar Then
HBar.Move 0, got_hgt - HBar.height, got_wid
HBar.Visible = True
Else
HBar.Visible = False
End If
If need_vbar Then
VBar.Move got_wid, 0, VBar.Width, got_hgt
'VBar.Move got_wid, 0, VBar.Width, got_hgt
VBar.Visible = True
Else
VBar.Visible = False
End If
findExtremePosition
If rightMost < OuterPict.Width Then
rightMost = OuterPict.Width
End If
If BottomMost < OuterPict.height Then
BottomMost = OuterPict.height
End If
InnerPict.Width = rightMost + 1000
InnerPict.height = BottomMost + 1000
SetScrollBars
Code for method "findExtemePosition"
Dim CTL As Control
TopMost = 0
BottomMost = 0
leftMost = 0
rightMost = 0
For Each CTL In Me
If TypeOf CTL Is PictureBox Then
If CTL.Top < TopMost Then
TopMost = CTL.Top
End If
If CTL.Top > BottomMost Then
BottomMost = CTL.Top + CTL.height
End If
If CTL.Left < leftMost Then
TopMost = CTL.Left
End If
If CTL.Left > rightMost Then
rightMost = CTL.Left + CTL.Width
'MsgBox Ctl.Caption
End If
End If
Next
Code for setScrollBars
VBar.Min = 0
VBar.Max = OuterPict.ScaleHeight - InnerPict.height
VBar.LargeChange = OuterPict.ScaleHeight
VBar.SmallChange = OuterPict.ScaleHeight / 5
HBar.Min = 0
HBar.LargeChange = OuterPict.ScaleWidth
HBar.SmallChange = OuterPict.ScaleWidth / 5
HBar.Max = OuterPict.ScaleWidth - InnerPict.Width
The max value exceed s -32768
and throws an overflow error,
when not even half my controls are seen.
Thanking in advance,
Sujith.K