|
-
Aug 30th, 2001, 06:08 AM
#1
Thread Starter
New Member
Scrolling picture boxes
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
-
Aug 30th, 2001, 02:51 PM
#2
Fanatic Member
Teaudirenopossum.Musasapientumfixaestinaure.
(I can't hear you. There's a banana in my ear)
-
Sep 3rd, 2001, 05:25 AM
#3
Thread Starter
New Member
7 times better
Thanks a lot.
That was 7 times better than the last one.
The 32 - bit scroll bar helps.
But now the limitation is the width of the picture box.
It stil doesnt fit in all the number of controls i need to .
Anyway thanks a lot for the help you have done.
Any more suggestions are most welcome.
Thanking you,
-
Sep 3rd, 2001, 05:35 AM
#4
PowerPoster
Hi sujiforo
Do u mind posting ur code including the actual event subroutines (ps type "[vbcode ]" (no spaces) before ur code and "[/vbcode ]" (no space) after ur code)
The reason i am asking is that i cant see how the scrolling of a pic box inside another pic can require so much code. I remember that it took less than 10 lines or so all up when i did before. Maybe if i can get ur code and look over it i can offer some suggestions.
Also, if u can tell me roughly how big each picture box is. If the picture boxes are bigger than the max prop of ur scroll bar have u considered simply scaling ur moves of the picture box to say 10 times for each scroll bar 1?
Regards
Stuart
-
Sep 3rd, 2001, 08:04 AM
#5
Thread Starter
New Member
That was my initial code.
Now I have a better option and the scroll bar width is much greater than the picture boxes' width.
thanks to psycho mark.
Just have a look at the code given there.
It is evry simple to use - the scroll bar control given in the site.
As i said -
now the problem is that the picture box width is not good enough to hold all controls.
U can try it for urself -
there seems to be a limitation in the number of controls the picture box can hold.
Please try the sample file given in the site
http://www.vbaccelerator.com/codelib...r/sbrclass.htm
Try adding some 500 text boxes to the picture box .
You will find what Iam talking about..
Thanks
-
Sep 3rd, 2001, 08:13 AM
#6
PowerPoster
500 text boxes????????
Emmm ok. Maybe look at a different design????
-
Sep 3rd, 2001, 08:23 AM
#7
Frenzied Member
500!
I once made a program with _alot_ of menus!!
when there was too many of them, vb told me that i couldnt add more...
-
Sep 3rd, 2001, 11:00 AM
#8
Try adding some 500 text boxes to the picture box .
I can not imagine a program who need 500 textbox in the same window, can you tell me what is your program is used to ?
-
Sep 3rd, 2001, 11:03 PM
#9
Thread Starter
New Member
Organization chart
It is an organization chart.
Every employee's position has to be shown in a hierarchy.
-
Sep 4th, 2001, 01:46 AM
#10
PowerPoster
. o O ( hmmm Treeview and Listview controls )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|