mCtrl
0.9.6
|
Go to the source code of this file.
Image view control (MC_WC_IMGVIEW
).
Image view control is specialized control for displaying an image. Unlike the standard STATIC
control which can only support bitmaps and icons, the image view control supports more image formats: BMP, ICON, GIF, JPEG, PNG, TIFF, WMF and EMF.
GDIPLUS.DLL
version 1.0 or newer to work correctly. This library was introduced in Windows XP and Windows Server 2003. If your application needs to use this control on Windows 2000, you may need to distribute GDIPLUS.DLL
along with your application. (Microsoft released GDIPLUS.DLL
1.0 as a redistributable for this purpose.)The control can display images loaded from a file as well as images embedded as resources in a DLL or EXE module. Note that window text as passed into CreateWindow()
is interpreted as a name of a resource in the same module as specified by the @ HMODULE handle passed into the function. It may also specify the integer ID of a resource with the MAKEINTRESOURCE
, or in the form "#123".
This allows to create the control and associate an image directly in the resource script:
Note the control only looks for image resources of the following resource types: RT_RCDATA
, RT_BITMAP
(bitmaps only), "PNG" (PNG only) or RT_HTML
. (The last option is the application uses the image also with the MC_WC_HTML
control).
It is also possible to set the image in the application run time.
Use message MC_IVM_LOADRESOURCE
to set the image from the resource of a DLL or EXE module. Note the application is responsible to ensure the module is not unloaded while the image is in use by the control I.e. until the control is associated with different image, or until the control is destroyed.
To load the image from a file, use the message MC_IVM_LOADFILE
.
By default, the image is scaled so that its aspect ratio is preserved, and as much of the control area is utilized as possible.
Application can change this behavior by specifying the style MC_IVS_REALSIZECONTROL
, which scales the image to the size of the control without preserving the aspect ratio; or by the style MC_IVS_REALSIZEIMAGE
which suppresses the scaling altogether.
Initialization Functions | |
BOOL | mcImgView_Initialize (void) |
void | mcImgView_Terminate (void) |
Window Class | |
#define | MC_WC_IMGVIEWW L"mCtrl.imgView" |
#define | MC_WC_IMGVIEWA "mCtrl.imgView" |
Control Styles | |
#define | MC_IVS_TRANSPARENT 0x00000001 |
When set, the control background is transparent. More... | |
#define | MC_IVS_REALSIZECONTROL 0x00000100 |
When set, the image is scaled to dimensions of the control. More... | |
#define | MC_IVS_REALSIZEIMAGE 0x00000200 |
When set, the image is painted in its original dimensions. More... | |
Control Messages | |
#define | MC_IVM_LOADRESOURCEW (MC_IVM_FIRST + 0) |
Load image from a resource (Unicode variant). More... | |
#define | MC_IVM_LOADRESOURCEA (MC_IVM_FIRST + 1) |
Load image from a resource (ANSI variant). More... | |
#define | MC_IVM_LOADFILEW (MC_IVM_FIRST + 2) |
Load image from a file (Unicode variant). More... | |
#define | MC_IVM_LOADFILEA (MC_IVM_FIRST + 3) |
Load image from a file (ANSI variant). More... | |
Unicode Resolution | |
#define | MC_WC_IMGVIEW MCTRL_NAME_AW(MC_WC_IMGVIEW) |
#define | MC_IVM_LOADRESOURCE MCTRL_NAME_AW(MC_IVM_LOADRESOURCE) |
#define | MC_IVM_LOADFILE MCTRL_NAME_AW(MC_IVM_LOADFILE) |
#define MC_WC_IMGVIEWW L"mCtrl.imgView" |
Window class name (Unicode variant).
#define MC_WC_IMGVIEWA "mCtrl.imgView" |
Window class name (ANSI variant).
#define MC_IVS_TRANSPARENT 0x00000001 |
When set, the control background is transparent.
#define MC_IVS_REALSIZECONTROL 0x00000100 |
When set, the image is scaled to dimensions of the control.
MC_IVS_REALSIZEIMAGE
. #define MC_IVS_REALSIZEIMAGE 0x00000200 |
When set, the image is painted in its original dimensions.
If the control is too small, only part of the image is painted.
MC_IVS_REALSIZECONTROL
. #define MC_IVM_LOADRESOURCEW (MC_IVM_FIRST + 0) |
Load image from a resource (Unicode variant).
[in] | wParam | (HINSTANCE ) Module providing the resource. |
[in] | lParam | (const WCHAR* ) Resource name. |
BOOL
) TRUE
on success, FALSE
otherwise.#define MC_IVM_LOADRESOURCEA (MC_IVM_FIRST + 1) |
Load image from a resource (ANSI variant).
[in] | wParam | (HINSTANCE ) Module providing the resource. |
[in] | lParam | (const char* ) Resource name. |
BOOL
) TRUE
on success, FALSE
otherwise.#define MC_IVM_LOADFILEW (MC_IVM_FIRST + 2) |
Load image from a file (Unicode variant).
wParam | Reserved, set to zero. | |
[in] | lParam | (const WCHAR* ) File path. |
BOOL
) TRUE
on success, FALSE
otherwise.#define MC_IVM_LOADFILEA (MC_IVM_FIRST + 3) |
Load image from a file (ANSI variant).
wParam | Reserved, set to zero. | |
[in] | lParam | (const char* ) File path. |
BOOL
) TRUE
on success, FALSE
otherwise.#define MC_WC_IMGVIEW MCTRL_NAME_AW(MC_WC_IMGVIEW) |
Unicode-resolution alias.
#define MC_IVM_LOADRESOURCE MCTRL_NAME_AW(MC_IVM_LOADRESOURCE) |
Unicode-resolution alias.
#define MC_IVM_LOADFILE MCTRL_NAME_AW(MC_IVM_LOADFILE) |
Unicode-resolution alias.
BOOL mcImgView_Initialize | ( | void | ) |
Registers window class of the control.
TRUE
on success, FALSE
on failure. void mcImgView_Terminate | ( | void | ) |
Unregisters window class of the control.