473,505 Members | 13,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

zooming using mouse wheel using C#

14 New Member
how can i do Zooming of a particular area using OnMouseWheel (that is zooming a mouse wheel point that should come into view with zoom ) using C#

Regards,
ALGATES
Aug 10 '08 #1
4 8556
Curtis Rutland
3,256 Recognized Expert Specialist
What have you tried so far. We can help you help yourself, but we can't do your work for you.

MODERATOR
Aug 10 '08 #2
alarock
14 New Member
Dear Moderator(INSERT ALIAS)
This is the concept I am trying but i want scroll bar in that .how can acheive it .?
http://www.codeproject.com/KB/graphics/PanZoom2.aspx?msg=2672101#xx2672101xx 01xx

I tried the concept of Autoscrollminsize and autoscrollposition but output is not working.
Please help me .If any thing which i done wrong in the previous post please forgive me.

Regards,
ALGATES
Aug 11 '08 #3
Curtis Rutland
3,256 Recognized Expert Specialist
You can download the working source code from the top of the page that you linked. Try to download the source, study it, see if you can't figure out what you are doing differently, and then let us know.
Aug 11 '08 #4
alarock
14 New Member
You can download the working source code from the top of the page that you linked. Try to download the source, study it, see if you can't figure out what you are doing differently, and then let us know.
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8.  
  9. namespace zoom_aug12
  10. {
  11.     public partial class Form1 : Form
  12.     {
  13.         private Bitmap bmp;
  14.         Graphics grfbmp;
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.  
  19.             bmp = new Bitmap(1000, 1000);
  20.             grfbmp = Graphics.FromImage(bmp);
  21.             Zoom =3F;
  22.         }
  23.         float _zoom = 1F;
  24.         public float Zoom
  25.         {
  26.             get
  27.             {
  28.                 return _zoom;
  29.             }
  30.             set
  31.             {
  32.                 _zoom = value;
  33.                 UPDA();
  34.             }
  35.         }
  36.         public void UPDA()
  37.         {
  38.             this.AutoScrollMinSize = new Size((int)(bmp.Width*Zoom),(int)(bmp.Height*Zoom));
  39.             Refresh();
  40.         }
  41.         protected override void OnLoad(EventArgs e)
  42.         {
  43.             Rectangle rect = new Rectangle(0, 0, 999, 999);
  44.             Pen penblue = new Pen(Color.Blue);
  45.             grfbmp.DrawRectangle(penblue,rect);
  46.             base.OnLoad(e);
  47.         }
  48.         private Rectangle _drawrect = new Rectangle(0, 0, 1000, 1000);
  49.         public Rectangle DRAWRECT
  50.         {
  51.             get
  52.             {
  53.                 return _drawrect;
  54.             }
  55.             set
  56.             {
  57.                 _drawrect = value;
  58.                 Refresh();
  59.             }
  60.         }
  61.         private PointF _viewportcenter;
  62.         PointF ViewPortCenter
  63.         {
  64.             get
  65.             {
  66.                 return _viewportcenter;
  67.             }
  68.             set
  69.             {
  70.                 _viewportcenter = value;
  71.             }
  72.         }
  73.         protected override void OnMouseWheel(MouseEventArgs e)
  74.         {
  75.  
  76.  
  77.             Zoom += Zoom * (e.Delta / 1200.0f);
  78.             if (e.Delta > 0)
  79.  
  80.                 ViewPortCenter = new PointF(ViewPortCenter.X + ((e.X - (Width / 2)) / (2 * Zoom)), ViewPortCenter.Y + ((e.Y - (Height / 2)) / (2 * Zoom)));
  81.              // DRAWRECT = new Rectangle((int)ViewPortCenter.X,(int)(ViewPortCenter.Y),(int)(Width/Zoom),(int)(Height/Zoom));
  82.  
  83.  
  84.             //base.OnMouseWheel(e);
  85.         }
  86.         protected override void OnScroll(ScrollEventArgs se)
  87.         {
  88.             DRAWRECT = new Rectangle(0, 0, 1000, 1000);
  89.             base.OnScroll(se);
  90.         }
  91.         protected override void OnPaint(PaintEventArgs e)
  92.         {
  93.             Graphics g = e.Graphics;
  94.             g.DrawImage(bmp, this.DisplayRectangle, DRAWRECT, GraphicsUnit.Pixel);
  95.             base.OnPaint(e);
  96.         }
  97.         }
  98. }

I studied well and i am trying with autoScrollminsize ,but scroll bar is not coming accurately.please help me.
Regards,
ALGATES.
Aug 12 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
6180
by: AccessWhiz | last post by:
I have been trying desperately for the past few days to figure out why the MouseWheel solution that I retrieved from the Lebans website won't work. The access database included with the solution...
0
2225
by: Jack | last post by:
Gday everyone, I'm dearly hoping Stephen Lebans is going to update his masterpeice to stop the mouse wheel scrolling to work on subforms *he has indicated this to me but of course beggers can't...
1
3401
by: jv | last post by:
I have quite a few of continuous form and subform where I do allow scroll bars. I run into problems with the mouse wheel whenever the data on the form does not take up the whole page. In this...
2
1390
by: CaptainWillard | last post by:
I am having a problem with Access 2000 for which I can't find an answer. My project opens a form with a new record, and one of the controls on the form is a combo box. If a user tries to navigate...
13
2779
by: Nathan | last post by:
Hi, Can someone lead me to info on detecting and using the mouse button? All I can find in the MSDN docs is that you use e.Delta, but it doesn't explain in how. I tried detecting the roll of...
4
2710
by: ML | last post by:
I am trying to use the mouse wheel event on a numeric input box to allow the use to scroll to inc/dec the value by 1. The issue I am having is that the delta value returned seems to be off. From...
7
2974
by: Martijn Mulder | last post by:
When the mouse is over a picture, the user can grow or shrink it by rolling the central mouse wheel. What behavior is typical when the user rolls the wheel away. Will the picture grow or shrink...
0
1582
by: sandeepshetty | last post by:
hi all.. Can anybody help me out on how zooming can be done on images in web applications but only by using mouse wheel and scroll bars.. thank u.. ...
3
1863
by: West55 | last post by:
I have an Access 2003 database I developed for one of my departments. I have been using Stephen Lebans' MouseWheelOnOff system to turn off the Mouse Wheel without any issues since I developed the...
0
7098
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...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7017
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...
0
5610
agi2029
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 project—planning, coding, testing,...
0
4698
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...
0
3187
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...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1526
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 ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.