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
get_resource_size() returns the size of the currently loaded resource or SIZE(0, 0) if there is no resource LoadImage() in your MSDN add_painter<resource_painter> (bg_wnd::res_info(IDI_BACKGROUND_WND, IMAGE_ICON));
The result is as follows
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
tile_size() sets and returns the current tile size. If the image is larger it will be clipped. By default the tile size is cx = 0, cy = 0 which means the painter shall determine the size of the image and use that sizeconst 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_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. |