473,837 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
SystemInformati on.VerticalScro llBarWidth 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 AutoScrollMinSi ze
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.

Nov 21 '05 #1
0 1522

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

Similar topics

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 scrollbars and then click on the map nothing happens. If i autoscroll to exactly the same location and click the control then the scroll panel moves back to the top left corner (the intial location). Has anyone had similar problems? If so what did...
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 something (for example a label) out side of visible part. When in design mode there is no problem, scrollbars automatically appears and works fine, but when i run (deploy) the
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. Here is the simplicied section of drawing code: private void panel_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { panel.AutoScroll = true;
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 value of autoscrollpos ... for ex say i make auotscrollpos to 30 . then after the call is over , it becomes say 40 .
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 that of the panel, so the panel scrolls up and down in order to accomodate both of them. The user can drag the Vscrollbar just fine and move about normally. This setup is probably easier to illustrate than describe verbally: ...
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
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; cell.RowNumber = dv.Count; m_DataGrid.CurrentCell = cell; } But this the last line of this code is putting the focus on the current
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. The imagebox is named panel2 for my own conventions and the panel will be named panel1 Panel2 (the imagebox) is set to fit to the size of Panel1 (the Panel). All of this works great... I have broken up an extremely large image (width wise, not mem...
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 can’t find the AutoScroll property. Do I need to set something up for this property? Any help would be appreciated. -- thank You
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.