473,785 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Erasing rectangle drawn with DrawRectangle

Dan
I want to use Graphics.DrawRe ctangle to draw a rectangle at a position on the
screen, and then a few seconds later, erase it. How do you erase a rectangle
that you just drew (without affecting the original background of the
window(s) behind the rectangle)?

Thanks...

Dan
Dec 22 '05 #1
2 3383
Dan wrote:
I want to use Graphics.DrawRe ctangle to draw a rectangle at a position on the
screen, and then a few seconds later, erase it. How do you erase a rectangle
that you just drew (without affecting the original background of the
window(s) behind the rectangle)?

Thanks...

Dan

If you force the background object (form, control, etc) to repaint
itself. You can use the invalidate method I believe.

Chris
Dec 22 '05 #2
> I want to use Graphics.DrawRe ctangle to draw a rectangle at a position on
the
screen, and then a few seconds later, erase it. How do you erase a rectangle
that you just drew (without affecting the original background of the
window(s) behind the rectangle)?


Try ControlPaint.Dr awReversibleFra me. Call it once to draw, call it again
with the same args to erase. The disadvantage is that you can't precisely
control the rectangle's color.
Dec 22 '05 #3

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

Similar topics

3
2464
by: | last post by:
I am having a hard time understanding the logic behind the Rectangle object. My problem has to do with the way the rectangle treats the "Width" property. For example, take the following rectangle object. Rectangle myRec = new Rectangle(0, 0, 2, 2); If you draw this rectangle on the screen you will end up with a rectangle like the one shown below (The character "X" represents a pixel used to draw the rectangle and the character "O" is...
3
10329
by: Colin McGuire | last post by:
Hi there. I have written a small procedure to draw various shapes on things. A bit of it is shown below. Private Sub drawShape(ByVal shapeType As Integer, ByRef g As Graphics) Select Case shapeType Case 1 : g.DrawRectangle(New Pen(Color.Black), 0, 0, 50, 10) Case 2 'draw a circle Case 3 'draw a triangle Case 4 'draw other shape Case 5 'draw other shape
4
2673
by: Colin McGuire | last post by:
Hi, this is a really simple question I have been banging my head on a brick wall over. The program below changes the background colour of a form depending on whether the cursor is inside a rectangle drawn on the form or not. It works perfectly as shown below. But it won't work if I change the values of scaleFactor, rotateFactor, translateFactorX, translateFactorY in the program. I would like to 'correct' the values of e.X and e.Y in...
1
1029
by: Morten Snedker | last post by:
Hey folks, I'm trying to make my own progressbar. The idea (for my test) is a rectangle that is 1/60 filled with a color per second (so after a minute it is all filled). This is what I have so far: Public Sub DrawRectangleFloat(ByVal e As PaintEventArgs)
5
4709
by: DazedAndConfused | last post by:
I have a rectangle around text that I want to fill in with color. I do not know the height of the rectangle until I actually go through and draw out the text. Is there a way of filling in the rectangle that will allow the text to show through? I did try: myColor = Color.FromArgb(127, Color.GreenYellow) Dim fillBrush As New SolidBrush(myColor) but that isn't exactly the effect I wanted.
2
3666
by: Andy Chen | last post by:
Hi, Now I can get the rectangle to draw, but it seems the rectangle is not visible. The following code is used to draw the rectangle. Hope someone can help. Thanks very much! SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Red); Pen pen = new Pen(brush, 4); Graphics formGraphics = Graphics.FromHwnd(this.axWebBrowser.Handle);
1
3779
by: Jeff Waskiewicz | last post by:
Hello All, I'm trying to solve a nagging problem. The goal is to draw a rectangle over the top of all the other controls on a form. Specifically, over a ChartFX control. The user would draw the rectangle using the right mouse button to represent the area of the chart they want to zoom on. I haev been able to draw the rectangle on a blank form but I cannot get it to draw on top of other controls. I have pasted in the code i am using ....
3
2086
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
I'm drawing text using the DrawString method. I need a way to go back and erase one or more characters. As a first thought it seemed that one way to do it would be to go back to the character(s) I want to erase and merely re-write the same character(s) using a brush whose foreground color is the same as the background color. The following code does that: protected override void OnPaint(PaintEventArgs pea) { Graphics grfx =...
4
27006
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 = e.X; //save original positions m_oldY = e.Y; //in the MouseMove event if (m_isDragging)
0
9645
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
10336
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
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...
1
10095
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,...
0
9953
tracyyun
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...
0
8978
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
7502
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
5383
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...
2
3655
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.