Results 1 to 10 of 10

Thread: Scrolling picture boxes

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    9

    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

  2. #2
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    9

    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,

  4. #4
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    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
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    9
    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

  6. #6
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    500 text boxes????????
    Emmm ok. Maybe look at a different design????
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  7. #7
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755

    Talking 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...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  8. #8
    DaoK
    Guest
    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 ?

  9. #9

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    9

    Organization chart

    It is an organization chart.
    Every employee's position has to be shown in a hierarchy.

  10. #10
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    . o O ( hmmm Treeview and Listview controls )
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width