Creating a rectangle having rubber band effect filled with transparent color



Hi All,

I have a requirement to draw a rectangle having rubber band effect. ie
when i click on one point of screen and starts dragging, a bounding
rectangle needs to be created and on dragging it should grow. Also i
need to fill this rectangle using a transparent color.

I am able to fill by using GDI+ as shown below in the code snippet.

Gdiplus::GdiplusStartup(&token, &gdiplusStartupInt, NULL);
Gdiplus::Graphics* pGraphics = new Gdiplus::Graphics(pDC-
GetSafeHdc());
Gdiplus::SolidBrush* pOpaqueBrush = new Gdiplus::SolidBrush(50, 255,0,
0);
pGraphics->FillPolygon( pOpaqueBrush,
(Gdiplus::Point* )pPolygonPointArray,4);

I am facing one issue with this code set
I am calling this set of code on mouse move event.Since the call is
happening on mouse move for each mouse move a rectangle filled with
color red having a transparency value of 50 is drawn. Hence each
rectangle will be overdrawn by another rectangle thus making a
gradient effect from top corner to bottom corner.
I want to avoid this behaviour i.e. on each mouse move i want to clear
the old filling. I can't use Graphics::Clear() because of some
framework restriction i am using.

Can any one suggest any other way to acheive this.

Thanks in Advance.

Sujil C
.



Relevant Pages

  • Re: Selecting Multiple Objects in Drawing Canvas
    ... >> Drawing toolbar) and dragging a rectangle around the objects to be ... >> Suzanne S. Barnhill ...
    (microsoft.public.word.drawing.graphics)
  • Re: Rendering performance while dragging
    ... To move a rectangle, click inside the rectangle and drag. ... > stretch a rectangle, drag its left or right edge. ... > I'm not very satisfied with the performance while dragging. ... > issued and each repaint paints everything which takes a while. ...
    (comp.lang.java.gui)
  • Re: Rendering performance while dragging
    ... > 2) While dragging, draw everything except the dragged rectangle from a ... and draw the dragged rectangle as usual. ...
    (comp.lang.java.gui)
  • Re: Inaccurate Guides
    ... The selection was simply made by dragging the ... marquis tool to form a rectangle. ... Snapped to the vertical guide fine, ...
    (alt.graphics.photoshop)
  • Re: Windows XP desktop
    ... Drag a rectangle to select all objects within the rectangle. ... Drag the rectangle to include an object or two and see what happens. ... You're also dragging even if you are not moving anything. ... a frame or box appear when the mouse is moved -- and then this frame or ...
    (microsoft.public.windowsxp.help_and_support)

Loading