473,395 Members | 1,554 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,395 software developers and data experts.

Drawing a rectangle with a mouse.........

3
Hi,

I have made an applicationa in C#(VS 2005), which allows the user to plot and zoom a graph.

while zooming, the user drags the mouse to specify a rectangular area, which is then magnified.

I would like to show this rectangle actually being created.

The problem is, the apllication creates a rectangle with every drag of the mouse,
thereby creating nearly 100-200 rectangles. I want only the last rectangle to be visible and erase the previos rectangles.


Any help is appreciated.
Thnx.
Apr 3 '07 #1
6 2909
RedSon
5,000 Expert 4TB
This is an advanced topic and we will need to see your rectangle drawing code. I suspect you will be detecting a mouse LBUTTONDOWN event and then starting to draw your rectangle from the X,Y coords of that point. But I would need to see that block of your code to tell you what is going on.
Apr 3 '07 #2
A2K
3
Hi,
I got the solution for it from the net.

The DrawReversibleFrame method automatically erases the previous rectangles.

ControlPaint.DrawReversibleFrame(thisform.Rectangl eToScreen(SelectRect), Color.Black, FrameStyle.Dashed);

If it could help you, I can send you the complete code.

bye.
Apr 4 '07 #3
RedSon
5,000 Expert 4TB
No need I was just curious.
Apr 4 '07 #4
On Similar Grounds... i am drawing a rectangle ..with mouse dynamically using mouse events ..

I want it to display the rectangle as i draw it .. something like in paint/ photoshop !! how do i do it ..>!!


thnx ;)
Apr 24 '07 #5
On Similar Grounds... i am drawing a rectangle ..with mouse dynamically using mouse events ..

I want it to display the rectangle as i draw it .. something like in paint/ photoshop !! how do i do it ..>!!


thnx ;)


Hi friend, i m working on the GIS using .Net platform.
I like to do zoom on image by using rectangle zoom.

so please if u have code for the same, please reply me.

thanx
Jan 30 '08 #6
Plater
7,872 Expert 4TB
Hi friend, i m working on the GIS using .Net platform.
I like to do zoom on image by using rectangle zoom.

so please if u have code for the same, please reply me.

thanx
Using the above posts as references, you should be able to figure out how to draw the "rectangles".
Once you have the rectangle, you can use Bitmap's CreateThumbnail() function to create a thumbnail with the coordinates of the rectangle.
You would then set that thumbnail image back to the picture displaying control and setting it's mode to stretch.
Jan 30 '08 #7

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

Similar topics

1
by: Philippe Meunier | last post by:
Hi, I would like to know How I could draw a Dashed rectangle over everything in a container. I will use this to draw a selection rectangle (like in VB.NET Form Designer UI). And even it draws in...
2
by: Champika Nirosh | last post by:
Hi, I want to create drawing board application that can draw Line, rectagle, circle and free hand drawing. Each drawing need to be transparent, moveable (draggable), have bring to front and...
6
by: johannblake | last post by:
I am wondering whether it is easy to setup a coordinate system for drawing (using GDI+) that uses meters (or any custom scaling for that matter). Currently, I need to convert from pixels to meters...
2
by: johnb41 | last post by:
My app has an image (black/white tiff) displayed in a picturebox (scanned text document). I need the user to be able to draw either white or black rectangles on it. (to hide/cover up sensitive...
2
by: psmukilan | last post by:
How to draw a rectangle using Javascript on the aspx page. This is like a selector control box. from the point of Mouse down till we release th mouse, it should draw the rectangle. Just like...
3
by: kamleshgk | last post by:
Hi, I have a requirement to draw a rectangle and a line on a the container control and sometimes as i move the mouse the drawing must occur on top of user controls and other controls, which are...
1
by: lab3terch | last post by:
Imports System.Drawing.Graphics Public Class Form1 Inherits System.Windows.Forms.Form Dim x1, y1, x2, y2 As Integer Dim red, black, blue, green, orange As Color Dim x, y, w, h...
4
by: RobinS | last post by:
I am drawing a rectangle on a picture that has already been drawn on the graphics area (a user control). It works something like this: //in the MouseDown event m_isDragging = true; m_oldX =...
5
by: Macias | last post by:
Hi, Please help me, how I can make a line drawing on PictureBox similar to MS paint. I thinking about this: click and hold button, move mouse and relase button. I'm trying useing this...
7
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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...
0
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
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,...

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.