L_ILM_SETITEM
Send this message to update the specified item in the ImageList Control.
Parameter |
Description |
WParam |
0-based index of the item to update. |
LParam |
Pointer to an LILITEM structure that contains new attributes for the item. |
Returns
SUCCESS |
Function was successful |
< 0 |
An error occurred. Refer to Return Codes. |
Comments
The LILITEM structure pointed to by lParam specifies the information to update the specified item with. The uMask member of the LILITEM structure indicates the attributes of the item to update.
You must set the uStructSize member of the LILITEM structure before using this message.
If you are including the LILITEM_BITMAP flag in the uMask member of the LILITEM structure, you must set the uBitmapStructSize member of the LILITEM structure before using this message.
Note: when you update an item, the image and text (if any) are copied to internal storage. The ImageList Control will free its copy of the image and/or text when the item is deleted. You are responsible for freeing the original data when it is no longer needed by your application.
The associated macro is:
L_ImgListSetItem(hWnd, uIndex, pItem)
For a complete list of available macros, refer to the Ltlst.h file.
See Also
Elements: |
L_ILM_GETITEMCOUNT, L_ILM_GETITEM, L_ILM_GETSELCOUNT, L_ILM_GETSELITEMS |
Topics: |
|
|
Example
L_INT ILM_SETITEMExample(HWND hCtrl) { if(IsWindow(hCtrl)) { LILITEM Item; L_TCHAR szText[200]; SYSTEMTIME st; BITMAPHANDLE Bitmap; L_INT nRet; /* load new image for the item */ ZeroMemory(&Item, sizeof(LILITEM)); nRet = L_LoadBitmap(TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\image1.cmp"), &Bitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); if(nRet == SUCCESS) { Item.uStructSize = sizeof(LILITEM); Item.pBitmap = &Bitmap; Item.uBitmapStructSize = sizeof(BITMAPHANDLE); Item.pText = szText; Item.bSelected = TRUE; Item.lData = 0; GetSystemTime(&st); wsprintf(szText, TEXT("%d:%d:%d"),st.wMinute,st.wSecond,st.wMilliseconds); /* update all attributes */ Item.uMask = LILITEM_BITMAP | LILITEM_TEXT | LILITEM_SELECTED | LILITEM_DATA; /* update the 3rd item with the new data */ nRet = (L_INT)SendMessage(hCtrl, L_ILM_SETITEM, 2, (LPARAM)&Item); /* update the control */ RedrawWindow(hCtrl, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); } return nRet; } else return ERROR_INVALID_PARAMETER; }