Actual size of a ScrolledWindow larger than its set and reported virtual size

I am using a scrolled window to view an image that is too large to fit on the screen. I do this by binding a function to wx.EVT_ERASE_BACKGROUND of the scrolled window that calls a function with dc = event.GetDC(), PrepareDC, and DrawBitmap. Let’s say I have a 500x300 image. I do a SetVirtualSize((500,300)) for the scrolled window. However, sometimes I am left with white space beyond the extent of the drawn bitmap. I verified that this space is actually beyond the virtual size by querying the mouse position, and I can get beyond the virtual size by around 5-7 pixels. I enclosed a simple program that somewhat recreates this issue. However, with this program, I was only able to get 1 pixel of extra border around the image.

program.py (1.99 KB)

You set the scrolling increment as 5, the letf-top corner will be anchored to 0, 5, 10,15…ect. But the size of the scrolled window is not an integral multiple of 5, that is why you see a strip on the end. You can eliminate this by SetScrollRate(1, 1) or just drawing your backgound bitmap a little bigger.(e.g. 805x605)

Mark

···

At 2013-09-29 09:02:30,hp34234 helicopter34234@gmail.com wrote:

I am using a scrolled window to view an image that is too large to fit on the screen. I do this by binding a function to wx.EVT_ERASE_BACKGROUND of the scrolled window that calls a function with dc = event.GetDC(), PrepareDC, and DrawBitmap. Let’s say I have a 500x300 image. I do a SetVirtualSize((500,300)) for the scrolled window. However, sometimes I am left with white space beyond the extent of the drawn bitmap. I verified that this space is actually beyond the virtual size by querying the mouse position, and I can get beyond the virtual size by around 5-7 pixels. I enclosed a simple program that somewhat recreates this issue. However, with this program, I was only able to get 1 pixel of extra border around the image.

That was it. Awesome, Thanks!

···

On Monday, September 30, 2013 9:09:34 AM UTC-4, Mark Weng wrote:

You set the scrolling increment as 5, the letf-top corner will be anchored to 0, 5, 10,15…ect. But the size of the scrolled window is not an integral multiple of 5, that is why you see a strip on the end. You can eliminate this by SetScrollRate(1, 1) or just drawing your backgound bitmap a little bigger.(e.g. 805x605)

Mark

At 2013-09-29 09:02:30,hp34234 helicopter34234@gmail.com wrote:

I am using a scrolled window to view an image that is too large to fit on the screen. I do this by binding a function to wx.EVT_ERASE_BACKGROUND of the scrolled window that calls a function with dc = event.GetDC(), PrepareDC, and DrawBitmap. Let’s say I have a 500x300 image. I do a SetVirtualSize((500,300)) for the scrolled window. However, sometimes I am left with white space beyond the extent of the drawn bitmap. I verified that this space is actually beyond the virtual size by querying the mouse position, and I can get beyond the virtual size by around 5-7 pixels. I enclosed a simple program that somewhat recreates this issue. However, with this program, I was only able to get 1 pixel of extra border around the image.