473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

AutoScroll issues

I am making a custom control that displays images, allows zooming in and
out, and can fit the image to the control. The way I am handling all of
this is probably not best, but I was looking for a quick and easy way to
at least get it working for now. I tried to keep this short, but I
couldn't find a way to.

The control has its Autoscroll property set to true. It contains a
PictureBox at 0,0 with its SizeMode set to StretchImage. When selecting
a zoom level, it basically resizes the PictureBox (for example, for a
200% zoom, it multiples the original height and width of the image by
2.) If the PictureBox is then larger than the control, it has scrollbars
because of the autoscroll property.

If the zoom is set to stretch to fit, it calculates a new height and
width based on the size of the control and the height to size ratio of
the original image. If the height of the image would be greater than
the height of the control, it subtracts the
SystemInformation.VerticalScrollBarWidth from the width it ends up using
when resizing the PictureBox, so that horizontal scrollbars are not
there when using stretch to fit.

I'm having two issues so far. Number one, I have it set to recalculate
and resize the PictureBox when the control is resized if stretch to fit
is selected as the zoom level. This works fine when resizing the
control to make it larger, or when maximizing, or restoring a previously
minimized window, as the size is getting larger. However, if I am
resizing the control/form it is on (is anchored top, right, bottom,
left) smaller and move the mouse at a normal rate (not just one pixel at
a time) it ends up drawing the scrollbars anyway, even though the image
is sized properly (the scrollbar width was subtracted when sizing.) If
I minimize, then restore the window, the scrollbar goes away, since it
considers it was resized from 0,0 to the new size (it got larger.) The
image itself is the exact same size (not a pixel different.)

Is this just a quirk with the Resize event?

The second issue I am having is with scrollbars being the incorrect
size. For example, if I set the zoom to 200%, the image is doubled in
size, and I can scroll to view the entire thing. If I then set the zoom
to 25%, the image is resized properly, but the vertical scrollbar is
extremely long. I can scroll down many times the length of the image.
I put in some Debug.WriteLine's to report some information. It was
reporting that the image was 820 pixels high, while the control was 650
pixels high. Obviously, there should only be a small amount of
scrolling to do, but I could probably scroll down as if the image was
2000 pixels high.

If I started at 25%, then went to 200%, I could only scroll through a
small portion of the image (as if it was barely any larger than the
control), but it reported that the image was over 3000 pixels high, yet
I only had a scrollable region of about 800-900 or so.

Are there known issues with the autoscroll? Would the AutoScrollMinSize
be any use to me here? Or should I just give up with autoscroll and add
a horizontal and vertical scrollbar to the control manually. I had
hoped autoscroll would kind of take care of this for me, but boy has it
been a headache.

Big thanks to anyone who took the time to read all of this.

Jeff
Nov 21 '05 #1
0 1501

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alexander Brown | last post by:
I have a custom control inside a frame. The frame has autoscroll set to true. The control has its dock set to Fill, and anchose set to top and left. If i scroll around the control using the...
0
by: Yasin Gedik | last post by:
Hello, I have a problem with autoscroll property. I am designing a form for pocket pc 2003 in whidbey, and deploying it to emulator. I set the forms Autoscroll property true and put...
1
by: John | last post by:
I'm trying to use the DrawText() method to draw some very long string text on the Panel with AutoScroll enabled. However, for some unknown reasons, I could not trigger the ScrollBar to show up. ...
0
by: amit bharadwaj | last post by:
hi all am using a panel , now i want to programitally set the thumb of autoscroll. for tht i have override wndproc() and try to set it .. ant it does .. but after that autoscroll too modify...
0
by: 23s | last post by:
I have 2 rich textboxes within an auto-scrolling panel object. The textboxes aren't wider than the panel, so it never scrolls horizontally. But the combined height of both textboxes is taller than...
5
by: Frank | last post by:
Hello, if autoscroll is true in a form. Is there a way to detect the scrollbars are active? Thanks Frank
21
by: Sharon | last post by:
I have added an auto scroll feature to my DataGrid control like this: private void DoAutoScroll() { DataView dv = m_DataGrid.DataSource as DataView; DataGridCell cell = m_DataGrid.CurrentCell;...
0
by: eweaver | last post by:
Hello, I have a problem with getting an autoscrollbar to end up where I want it. Things to know about the prob: I have an imagebox inside of a Panel for (inheritance of) autoscroll capabilities....
1
by: =?Utf-8?B?R3VzIENodWNo?= | last post by:
I’m working on a GroupBox and need to set the AutoScroll property to true. My problem is I have no AutoScroll property listed in the property box. And even if I go in to the Designer.cs file I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.