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

resource_painter

resource_painter lets you load resources from a module (exe or dll) and draws them. Supported resources are bitmaps, icons and cursors. If the resource is larger than the drawing-rectangle of the painter the resource will be clipped.

namespace win32 { namespace gui {

     namespace bg_wnd {

          struct res_info
          {
               static HINSTANCE module_handle();
               
               res_info(unsigned nResource, unsigned uType, int cx = 0, int cy = 0, unsigned fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, HINSTANCE hInst = module_handle());
               res_info(const char* pchResource, unsigned uType, int cx = 0, int cy = 0, unsigned fuLoad = LR_DEFAULTCOLOR | LR_DEFAULTSIZE, HINSTANCE hInst = module_handle());
               
               const char* pchResource_;
               unsigned    uType_; 
               int         cx_;
               int         cy_;
               unsigned    fuLoad_;
               HINSTANCE   hInst_;
          };

     }    // namespace bg_wnd

     // ========================================================================================================= //

     namespace detail {

          struct resource_painter_base : painter_base
          {
               typedef const bg_wnd::res_info& param0;
               
               void load_resource(const bg_wnd::res_info& info);      
               SIZE resource_size() const;
          };

     }    // namespace detail

     // ========================================================================================================= //

     class resource_painter : public detail::resource_painter_base
     {
     public:
          // c'tor
          resource_painter(const bg_wnd::res_info& info);
          
          // virtual functions of painter_base
          resource_painter* clone() const;
          void draw(HDC hDC, int cx, int cy);     
     };   

} }  // namespace win32::gui

Note:


Example:
add_painter<resource_painter> (bg_wnd::res_info(IDI_BACKGROUND_WND, IMAGE_ICON));

The result is as follows

resource_painter.jpg

tile_resource_painter

The tile_resource_painter does the same as the resource_painter with the difference that the resource will be displayed in tiles. You can optionally set the size of the tiles.

namespace win32 { namespace gui {

     class tile_resource_painter : public detail::resource_painter_base
     {
     public:
          typedef SIZE param1;

          // c'tor
          tile_resource_painter(const bg_wnd::res_info& info);
          tile_resource_painter(const bg_wnd::res_info& info, SIZE tile_size);
          
          // virtual functions of painter_base
          tile_resource_painter* clone() const;
          void draw(HDC hDC, int cx, int cy);     
          
          // own functions
          void tile_size(SIZE tile_size);
          SIZE tile_size() const;
     };

} }  // namespace win32::gui

Note:


Example:
const SIZE tile_size = ...;
add_painter<tile_resource_painter> (bg_wnd::res_info(IDI_BACKGROUND_WND, IMAGE_ICON), tile_size);

The result is as follows
tile_resource_painter_16_16.jpg
tile_resource_painter_0_0.jpg
tile_resource_painter_45_45.jpg
tile_size = { 16, 16 } tile_size = { 0, 0 } (determine resource size) tile_size = { 45, 45 }



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