Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
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

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us