Results 1 to 8 of 8

Thread: Bloody Scrollbars!

  1. #1

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Unhappy Bloody Scrollbars!

    I'm trying to scroll a bitmap in a picture box using 2 scrollbars like you'd expect.

    But the code only works if I set the Largechange property of the scrollbars to 0. If I use a number greater than 0 then the bitmap appears in the wrong place.

    I can't see how LargeChange should make any difference.

    What is the normal method for showing a bitmap in a picturebox using scrollbars?

    Code would be great, please.
    I don't live here any more.

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  3. #3

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    That'll do nicely, thanks.

  4. #4
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    lol it's really weird how someone else asked the same question again in a short time

    btw pax, I was getting some weird errors. One thing that was really really weird was that at certain times (I think when I scrolled really fast repeatedly? cant remember what I did)... scrollbar.value would have a value greater than scrollbar.maximum (whitout raising any errors) and so I had to check the Value property outside of the scrollbar class to make sure its on the right range...
    also in another situation ( I dont remember again when this would happen)... when I would change the value of Maximum it wouldnt change anything. It was weird because after calling the function 3 times it would then work fine. I just took a backup of LargeChange before changing the maximum and it fixed it:
    VB Code:
    1. Public Shadows Property Maximum() As Integer
    2.         Get
    3.             ' Return the real maximum
    4.             Return MyBase.Maximum - Me.LargeChange + 1
    5.         End Get
    6.         Set(ByVal Value As Integer)
    7.             ' Calculate the 'virtual' maximum
    8.             Dim tmp As Integer = MyBase.LargeChange
    9.             MyBase.Maximum = Value + Me.LargeChange - 1
    10.             MyBase.LargeChange = tmp
    11.         End Set
    12.     End Property



    anyways wossname why are you using a scrollbar for scrolling an image? you can just use a panel, put the picturebox in it, and set the AutoScroll property of the panel to true. It would do everything for you nicely. I had to use these scrollbars because I'm drawing my image manually, dunno about you
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  5. #5

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Originally posted by MrPolite
    anyways wossname why are you using a scrollbar for scrolling an image? you can just use a panel, put the picturebox in it, and set the AutoScroll property of the panel to true. It would do everything for you nicely. I had to use these scrollbars because I'm drawing my image manually, dunno about you
    Now you bloody tell me. This .net crap is like learning programming all over again.

    In my day we had VB6. I could have written this damn program in 3 hours and had done with it. I'll try the panel version.



    Thanks for the tip though
    I don't live here any more.

  6. #6

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    I've tried that, but the scrollbars on the panel don't appear when the image loads.

    Autosize and autoscroll on the respective controls are set true but nothing happens when a large picture is shown. I'm setting the Image property of the picturebox to a bitmap loaded using

    Code:
    PicMaster.Image = new Bitmap(Bitmap.FromFile(MyFileName))
    What (else) am I doing wrong?

  7. #7

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Never mind, I've got it working.

    I must say though, the scrolling was much smoother when I was drawing the image manually with Graphics.DrawImage().

    I might go back to that.

  8. #8
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by wossname
    Never mind, I've got it working.

    I must say though, the scrolling was much smoother when I was drawing the image manually with Graphics.DrawImage().

    I might go back to that.
    hehe why was it smoother?
    care to post your code so I see what you're doing?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

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