Winforms filled rubber band

How can I draw a rubber tape with zero opacity in the shape of a window with 0.3 opacity? (Rubber band made after Microsoft example


Update:

I need this rubber band to work something like a mask. If you use Jing or any other screen capture tool, you will see EXACTLY what I need to do when you try to take a screenshot: the screen becomes translucent, and when you make a selection, you will see an opacity selection of 0

+6
c # winforms drawing
source share
4 answers

Are you looking for this droid?

public Form1() { InitializeComponent(); DoubleBuffered = true; } bool mouseDown = false; Point mouseDownPoint = Point.Empty; Point mousePoint = Point.Empty; protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); mouseDown = true; mousePoint = mouseDownPoint = e.Location; } protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); mouseDown = false; } protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); mousePoint = e.Location; Invalidate(); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (mouseDown) { Region r = new Region(this.ClientRectangle); Rectangle window = new Rectangle( Math.Min(mouseDownPoint.X, mousePoint.X), Math.Min(mouseDownPoint.Y, mousePoint.Y), Math.Abs(mouseDownPoint.X - mousePoint.X), Math.Abs(mouseDownPoint.Y - mousePoint.Y)); r.Xor(window); e.Graphics.FillRegion(Brushes.Red, r); Console.WriteLine("Painted: " + window); } } 
+6
source share

When drawing, it is necessary to use a partially opaque color:

Updated line from a related article in the MyDrawReversibleRectangle method:

 ControlPaint.DrawReversibleFrame( rc, Color.FromArgb(80, 120, 120, 120), FrameStyle.Dashed ); 
+1
source share

I used the code that @Dearmash comes with in the screen capture utility that comes with my open source BugTracker.NET application. The application is not very large, so if you are doing screen capture, this could be a good starting point. More details here:

http://ifdefined.com/blog/post/Screen-capture-utility-in-C-NET.aspx

+1
source share

Just use the optional form without showing it on the taskbar or other form options. Set the area of ​​the form in which only the rubber band is displayed. And make sure that both windows behave as if it is one window (move, close, ...). I know that this is not an elegant way, but with little work it can give good results. You can make sure that the form is on top of the hierarchy of forms and still does not receive focus.

Having established the region well, all events will move to a different form.

The way I developed the equivalent problem (I'm not saying this is a good solution, but it works)

0
source share

All Articles