|
|
|
date: Thu, 3 Jul 2008 02:33:30 -0700 (PDT),
group: microsoft.public.win32.programmer.gdi
back
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
date: Thu, 3 Jul 2008 02:33:30 -0700 (PDT)
author: unknown
Re: Creating a rectangle having rubber band effect filled with transparent color
I guess it is not necessary to paint the rectangle on every mouse move
message, you can calculate the delta of the rectangle ( the new rectangle -
old rectangle ) and paint only that part. you can use the SubstractRect to
get it done without extra coding.
> 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
date: Sun, 6 Jul 2008 23:54:05 +0200
author: Saju
|
|