EQuestionAnswers.com Computer/Electronics Questions and Answers
C, C++, VC++, COM/DCOM, DLL and more
#Login #Sign up  Facebook Twitter TGoogle+
 

#Previous question #Index of VC++/WIN32/MFC Questions #Next question

Image list overview

Image list as the name suggest is a container to hold an array of images that can be used in other controls in the application. Image list is not an independent GUI element like button or textbox which user can interact with. Rather image list is maily an invisible control and used indirectly in the toolbars, list or tree controls. Image list generally holds a group of icons, bitmaps or images for the use of other controls. We see toolbars have new, open, save buttions or Windows explorer has icons for files and folders. All these icons are loaded in an image list then they are used. Toolbars, Tree and list control have APIs to associate an image list to itself. Later those controls directly uses the images from the list control.

Image list library calls

Windows common control controls library provides a collection of APIs for verious controls including Image list. ImageList_Create is the API to create the image list. Developers then need to add images to the list. ImageList_Add API is generally used for this purpose. This image list can be used to display verious icons and images in list view or tree view. SetImageList is the API to associate the image list object to the list view or tree view.

ImageList APIs

Here is the full list of ImageList utility APIs. Each API does a certain operation on the image list. Opertion name is appended with API nameand thus developer can easily choose the APIs to be used in their application. MSDN has full documentation on these APIs.

    ImageList_Add
    ImageList_AddMasked
    ImageList_BeginDrag
    ImageList_CoCreateInstance
    ImageList_Copy
    ImageList_Create
    ImageList_Destroy
    ImageList_DragEnter
    ImageList_DragLeave
    ImageList_DragMove
    ImageList_DragShowNolock
    ImageList_Draw
    ImageList_DrawEx
    ImageList_DrawIndirect
    ImageList_Duplicate
    ImageList_EndDrag
    ImageList_GetBkColor
    ImageList_GetDragImage
    ImageList_GetIcon
    ImageList_GetIconSize
    ImageList_GetImageCount
    ImageList_GetImageInfo
    ImageList_LoadImage
    ImageList_Merge
    ImageList_Read
    ImageList_ReadEx
    ImageList_Remove
    ImageList_Replace
    ImageList_ReplaceIcon
    ImageList_SetBkColor
    ImageList_SetColorTable
    ImageList_SetDragCursorImage
    ImageList_SetIconSize
    ImageList_SetImageCount
    ImageList_SetOverlayImage
    ImageList_Write
    ImageList_WriteEx

ImageList Example

HIMAGELIST hLarge;
HIMAGELIST hSmall;

void CreateImageList(void)
{
    HICON hiconItem;
    HMODULE hDll;

    // Create the full-sized icon image lists. 
    hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), 
                              GetSystemMetrics(SM_CYICON), 
                              ILC_COLOR32|ILC_MASK, 1, 1); 

    hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), 
                              GetSystemMetrics(SM_CYSMICON), 
                              ILC_COLOR32|ILC_MASK, 1, 1); 

    hDll = LoadLibrary ( "SHELL32.dll" );
    // Add an icon to each image list.  
    hiconItem = LoadIcon (hDll , MAKEINTRESOURCE ( 3));

    ImageList_AddIcon(hLarge, hiconItem);
    ImageList_AddIcon(hSmall, hiconItem);
}

void SetImageList(HWND hWndListView)
{
	ListView_SetImageList(hWndListView, hLarge, LVSIL_NORMAL); 
    ListView_SetImageList(hWndListView, hSmall, LVSIL_SMALL);
}
void DestroyImageList(void)
{
	ImageList_Destroy(hLarge);
	ImageList_Destroy(hSmall);
}

You have viewed 1 page out of 109. Your VC++ learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

#Programming Windows, Fifth Edition (Developer Reference)
#Programming Applications for Microsoft Windows (Microsoft Programming Series)
#Programming Windows with MFC, Second Edition
#Visual C++ Programming
#Programming Microsoft Visual C++, Fifth Edition

* #1 webmaster Sun 27 Apr/2014 22:35:22(GMT)  Like 0 Unlike 0

Dear Users,

We are pleased to inform you that a forum/blog has been incorporated with www.mybestnotes.co.in. You are welcomed to add your comments, requests, codes, solutions and feedback to it. Please login(if already a member) or signup(for free) to avail to this facility.

Regards,
Webmaster

Your message goes here:

Name:Guest
Email:anonymous@unknown.com
My Post:*
Secutiry Code: ******  *
Preview this compose before posting this in discussion forum.
 
Note:
  1. Use [Sxx] code to show smiles. Example [S02]
  2. Use [URL ], example [URL http://www.google.com/]
  3. To display code or un formatted text use [CODE] [/CODE]. Example: [CODE] printf("Hello world"); [/CODE]
 [S01]   [S02]   [S03]   [S04]   [S05]   [S06]   [S07]   [S08] 
 [S09]   [S10]   [S11]   [S12]   [S13]   [S14]   [S15]   [S16] 
 [S17]   [S18]   [S19]   [S20]   [S21]   [S22]   [S23]   [S24] 

Note: Only members are allowed, * fields are mandatory.