473,605 Members | 2,590 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 8563
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(INSER T 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?m sg=2672101#xx26 72101xx 01xx

I tried the concept of Autoscrollminsi ze and autoscrollposit ion 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 autoScrollminsi ze ,but scroll bar is not coming accurately.plea se help me.
Regards,
ALGATES.
Aug 12 '08 #5

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

Similar topics

6
6190
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 responds to the the wheel regardless of the button. In my application I get an error message when I try to set the class. I'm hoping that I can get some help (cause I feel really stupid right now). Before we go too much further, I am using a...
0
2233
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 be choosers here so I have no idea when this would be done*. I'm just wondering if anyone has gotten around the problem some other way? --Original Thread---
1
3418
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 instance, whenever a user uses the mouse wheel to scroll down, the first record disappears off the screen and they can't get it back unless they click on the Refresh button or Page Up. The mouse wheel never scroll back up to the first record. ...
2
1393
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 the combo box choices using the mouse wheel, the wheel mouse scrolls through all the records in the table the form is bound to. The combo box is still open, but the user ends up thinking all the data on the main form has changed. Is there any...
13
2794
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 the wheel in the frm.MouseDown, but it didn't detect it. Thank for the help.
4
2718
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 my understanding the delta is the number of detents the mouse has moved. The standard detent is supposedly 120 for one notch of the wheel, however when I turn the wheel 1 click I get 240. Is there someway to determine the actual detent setting...
7
2981
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 then?
0
1604
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.. sandeep.
3
1872
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 database. Recently my IT department replaced all the PCs and now I am having issues with the Mouse Wheel Off. If one of the radio buttons has focus, the mouse wheel works and scrolls to the next record. If one of the text boxes has focus, the mouse...
0
8004
marktang
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7934
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,...
0
8418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6743
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, and deployment—without 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...
1
5886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3912
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...
0
3958
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2438
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
0
1271
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.