Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

transparent_painter

transparent_painter is very similar to stretch_painter. It also aggregates another painter by deriving from painter_holder. But instead of stretching the aggregated painter it draws a color transparent. It is even possible to draw more than one color transparent - take a transparent_painter which holds a transparent_painter which holds some painter. Although not very efficient this is possible. Note that transparent_painter has no resource leak on Win9x (thanx to Raja Segar at codeproject.com)!

namespace win32 { namespace gui {

     class transparent_painter : public painter_base, public painter_holder
     {    
     public:
          typedef COLORREF param0;

          // c'tor
          transparent_painter(COLORREF crTransparent);
          
          // virtual functions of painter_base
          transparent_painter* clone() const;
          void draw(HDC hDC, int cx, int cy);

          // own functions
          void transparent_color(COLORREF crTransparent);
          COLORREF transparent_color() const;
     };

} }  // namespace win32::gui

Note:


Example:
// transparent color
COLORREF cr_white = RGB(255, 255, 252);

// create transparent_painter
transparent_painter p_transparent(cr_white);
p_transparent.set_painter<tile_resource_painter> (bg_wnd::res_info(IDI_BACKGROUND_WND, IMAGE_ICON));

// add the transparent_painter and draw. also set bk-color so that we can recognize the effect better ;-)
add_painter(p_transparent);
bk_color(RGB(150, 0, 0));

The result is as follows

transparent_painter.jpg



by Steven Weiss. You can contact me at steven11@gmx.de.