Results 1 to 17 of 17

Thread: VB6 Picturebox cannot scroll beyond Y position : -245760

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    New Zealand
    Posts
    27

    VB6 Picturebox cannot scroll beyond Y position : -245760

    Hu Guys. haven't been here for ages.

    I am looking at fixing old VB6 app where a PDF doc is exported to JPG images.
    The app needs to bitblt the images into one (or few) picture boxes and allow scrolling through the pages as a PDF reader does.
    And image overlay is used to make annotations to the contents of the pages.

    The problem is that if the document is larger that 10 pages, the picture box cannot scroll beyond -245760 in the Y position.
    I am trying to find a way around this limitation, but so-far, no luck.

    Anybody here that can help ?

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    Is the AutoRedraw property set to true? How did you design your scrolling picturebox? How is it scrollable (APIs, picbox inside picbox, something else)?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    There's a limit to the size of a picture box image. I don't remember what it is but wouldn't it make sense if you reach or exceed this limit you wouldn't be able to scroll beyond that point either vertically or horizontally. I did a project some time back where I needed to scroll vert. and horz. for a very long time (so to speak). For my project to work I had to create new picture boxes and size them to their maximum sizes and then "glue" them together at the edges in order for me to scroll and give the appearance of a never ending scrolling image.

    I'm not sure as I don't remember where I put that project but I think the method I used was to scroll a picturebox within a picturebox.
    Last edited by jmsrickland; Jul 22nd, 2015 at 10:58 AM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    New Zealand
    Posts
    27

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    Quote Originally Posted by LaVolpe View Post
    Is the AutoRedraw property set to true? How did you design your scrolling picturebox? How is it scrollable (APIs, picbox inside picbox, something else)?
    @LaVolpe: Yes, autoredraw = True
    Scrolling is done with Picturebox inside picturebox with VScroll on the form. Container picturebox is a view port of the content of the contained picturebox(es).
    Scrolling is done like this:

    Private Sub VScroll1_Change()
    Dim tp As Long 'used long as the VScroll value defaults to max int 32767
    Dim x As Integer

    tp = VScroll1.Value
    Picture1(0).Top = tp * -100 'this is why I needed a Long. fails on int value * -100
    For x = 1 To Picture1.UBound
    Picture1(x).Top = Picture1(x - 1).Top + Picture1(x - 1).Height
    Next
    End Sub

    Since the height of the picturebox is large : larger than 200 000 twips, and the scroll value literally can only hold the value 32767, I factored it to 100
    the code above shows the factor being applied to the top position
    also taken into account the fact that only 6 pages exceeds the max height of the picture box, I inly populate 5 pages and create a new picture box for the next 5, hence the loop to align them with the position of the top (first) picture box

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    New Zealand
    Posts
    27

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    @jmsrickland: Thanks, yes, I saw that and did exactly what you mentioned to glue them together. The problem is that when after I glued them together, it was able to place all the pages, but they cannot be scrolled to the end, but only to the max value of -245760

  6. #6
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    When you say -245760 are you talking about picturebox.top cannot be < -245760) or scrollbar value cannot be < -245760
    Last edited by jmsrickland; Jul 23rd, 2015 at 01:34 AM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  7. #7
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    Take a look here
    Using scrollio with dib inside we can repaint only the visible part of picture so we don't need to have all picture in a picturebox and then use extremely large moves using left and top properties

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    New Zealand
    Posts
    27

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    Quote Originally Posted by jmsrickland View Post
    When you say -245760 are you talking about picturebox.top cannot be < -245760) or scrollbar value cannot be < -245760
    @jmsrickland: The picturebox.top cannot be < -245760 or > cannot be > 245760
    The scrollbar Max value can only hold 32767 as it is an integer -> hence I divide the value with 100 when setting the max value and multiply it again when reading the scroll value

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    New Zealand
    Posts
    27

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    will certainly look at this. will let you know. It also means my overlay image control on which the annotations are done must behave the same

  10. #10
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    VB controls have max coordinates & sizes, likely limited by Integer (2 byte values). For example, even with a small picturebox, moving it left continuously, it max'd out at -245760 twips or -16384 pixels.

    So, you may want to rethink how you are doing this. If the 1st picbox is scrolled up so that it's bottom can no longer be viewed and the .Top property is well within the limitation, there is no need to keep scrolling it. Maybe a workable solution is to keep track of it's virtual .Top, i.e., a Long value indicating what would be the .Top property if you were allowed to keep scrolling. However, when the physical .Top value is exceeded that completely scrolls the picbox from view, stop scrolling. Thinking out loud
    Code:
     removed
    Edited: Maybe something like this. Should work easily enough. Excuse any typos
    Code:
    ' 2 new form-level variables
    Private m_Top() As Long
    Private m_VChange As Long
    
    -------------------------------------------------------------------------
    ' whenever picboxes are initially loaded....
    Dim x As Long
    ' load/unload pictureboxes as needed
    ReDim m_Top(Picture1.LBound To Picture1.UBound)
    ' m_Top(0) already=0 :: change if needed
    For x = Picture1.LBound + 1 to Picture1.UBound
        m_Top(x) = m_Top(x - 1) + Picture1(x - 1).Height
    Next
    m_VChange = 0 ' reset to whatever VScroll1 should initially be
    If VScroll1.Value = m_VChange Then
        Call VScroll1_Change()
    Else
        VScroll1.Value = m_VChange
    End If
    -------------------------------------------------------------------------
    
    Private Sub VScroll1_Change()
    Dim tp As Long, bPlaced As Boolean, x As Integer
    
        tp = m_VChange - VScroll1.Value 
        For x = Picture1.LBound To Picture1.UBound
            ' only scroll picboxes that would end up being visible in the view port
            m_Top(x) = m_Top(x) + tp
    
            ' add code to test for intersection between picturebox & view port
            ' if intersection exists, set bPlaced to True 
            ' picbox top & bottom: m_Top(x), m_Top(x)+Picture1(x).Height-1
    
            If bPlaced Then
                  bPlaced = False
                  Picture1(x).Top = m_Top(x)
            Else
                  Picture1(x).Top = picViewPort.ScaleHeight
            End If
        Next
    End Sub
    Last edited by LaVolpe; Jul 23rd, 2015 at 02:05 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  11. #11
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    As for the scrollbar you could make your own custom scrollbar control


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  12. #12
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    >Scrolling is done with Picturebox inside picturebox with VScroll on the form. Container picturebox is a view port of the content of the contained picturebox(es).

    So if the outer PictureBox has Scalemode = vbTwips the dimensions of the inner PictureBox represent large numbers; however if the outer PictureBox is ScaleModed in vbMillimeters, vbCentimeters, vbInches those dimensions will be much smaller numbers and within the limits of those for the Scrollbar Controls.

  13. #13
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    Quote Originally Posted by Magic Ink View Post
    So if the outer PictureBox has Scalemode = vbTwips the dimensions of the inner PictureBox represent large numbers; however if the outer PictureBox is ScaleModed in vbMillimeters, vbCentimeters, vbInches those dimensions will be much smaller numbers and within the limits of those for the Scrollbar Controls.
    Though the limits of the scrollbar may be an issue or just a red herring in this particular case, the real issue is the .Top property that cannot exceed a min/max limit set by VB (and/or Windows). The answer, in my opinion, is to stop scrolling it once the picturebox is completely outside the view port
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  14. #14
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    I think if you just "glue" one picturebox to the previous while scrolling vertically then you only need to scroll the last picturebox added. When that picturebox reaches it's max then "glue" another on top of it (or below it depending on direction of scroll) and scroll this new picturebox that was just added. Seems I did something like this when I needed a never ending scroll to my picturebox within a picturebox. I remember it didn't use scrollbars because the picture was scrolled by moving the mouse up and down (and left and right) but the effect was the same and it appeared as though there was no end to the scrolling. Somewhere in this Forum is the thread that I opened for that purpose which had to do with a scrolling map of the world and I needed it to scroll forever where each picturebox contained a portion of the map and it was resolved and I believe it was LaVolpe that gave the the answer how to keep scrolling the picturebox or something like that.
    Last edited by jmsrickland; Jul 23rd, 2015 at 02:40 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  15. #15
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    The problem as I understand is the way mr wbeetge want to place over an annotation control. He is totally mess all the job because control supposed to respond to mouse so he want real position on the picture to scroll, and real position to that picture too.
    So he must rethink the situation. I give an address in post #7 to a scrollio control. The real image and the viewport (the part of the image where we display in a picture box), are two different things. We can translate any viewport coordinate to image coordinate, easy. We gain an easy zoom function, because we never zoom the actual image (only for wmf we can change the rendering quality, but this is a second part, not for now).
    So the problem now is limmited to how we can put a control over the viewport. We can use a targeting system by using an array of targeting area and in any click on view port we translate the coordinates to image coordinates and we can check if we hit some target and then we can do whatever we want We need a way to render not only the image in the viewport but the included annotations. Now we can create a buffer, a second image where we copy the original image and then we place the annotations. We can use a third buffer if we want to place annotations while user scroll the viewport. So Original image and annotations, as functions, produce buffer A while user scroll buffer B in viewport
    For easy start up, wbeetge, make an example with one annotation.

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    New Zealand
    Posts
    27

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    @jmsrickland : Yes, I decided to do exactly that. All pages (Picture boxes) are invisible except for the current page in the viewport, the next page as well as the previous page. As each current page scrolls out of the viewport, either up or down , the next page glued and made visible depending in the direction one is scrolling. By the time the next or the prev page is scrolled into the viewport, it is seamless and the next is already buffered.
    Tested with 105 page document and looks great. The annotations are saved in metadata and printed on the overlay which is also now broken up in pages and works on exactly the same principle.
    Thanks for your input guys. Much appreciated

  17. #17

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    New Zealand
    Posts
    27

    Re: VB6 Picturebox cannot scroll beyond Y position : -245760

    @Magic Ink: I can try that but currently I divide the max value my 100 and when the event triggers, I just multiply it back again. smallchange value of 100 is too slow, so I set it to 3, so it becomes 300 when I scale the movement and it look smooth enough. Should I need better scrolling management, I will sure try your suggestion
    Thanks

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