L_ILM_GETSELITEMS

Send this message to get the currently selected items in the ImageList Control.

Parameters

wParam

Ignored, use 0.

lParam

Pointer to a caller-allocated array of LILITEM structures to be filled with the selected items.

Returns

Value Meaning
>=0 The number of items currently selected and pointed to by lParam
< 0 An error occurred. Refer to Return Codes.

Comments

The return value is the number of items pointed to by lParam.

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.

You must allocate the array to be large enough to hold the selected items and free the memory when it is no longer needed by your application.

If you pass NULL for lParam, the message will simply return the current number of selected items.

The LILITEM structure for each selected item will contain all attributes for the item. The lIndex member of the structure will contain the 0-based index of the item.

The associated macro is:

For a complete list of available macros, refer to the Ltlst.h file.

See Also

Elements

Topics

Example

L_INT ILM_GETSELITEMSExample(HWND hCtrl) 
{ 
   if(IsWindow(hCtrl)) 
   { 
      L_INT nRet; 
      L_TCHAR szText[200]; 
      L_TCHAR szMsg[200]; 
      pLILITEM pItems=NULL; 
      pLILITEM pTemp=NULL; 
      L_INT32 x; 
 
      /* Get selected item count */ 
      nRet = (L_INT)SendMessage(hCtrl, L_ILM_GETSELITEMS, 0, 0L); 
      if(nRet > 0) 
      { 
         /* allocate the storage */ 
         pItems = (pLILITEM)malloc(nRet * sizeof(LILITEM)); 
         ZeroMemory(pItems, nRet * sizeof(LILITEM)); 
         pTemp = pItems; 
         for(x=0; x<nRet; x++) 
         { 
            pTemp[x].uStructSize = sizeof(LILITEM); 
            pTemp[x].uBitmapStructSize = sizeof(BITMAPHANDLE); 
         } 
         /* Get selected items */ 
         nRet = (L_INT)SendMessage(hCtrl, L_ILM_GETSELITEMS, 0, (LPARAM)pItems); 
 
         pTemp = pItems; 
         lstrcpy(szMsg, TEXT("")); 
         if(pItems) 
         { 
            for(x=0;x<nRet;x++) 
            { 
               wsprintf(szText, TEXT("%s at index %ld\n"), pTemp[x].pText, pTemp[x].lIndex); 
               lstrcat(szMsg, szText); 
            } 
            /* free the storage */ 
            free(pItems); 
         } 
         MessageBox(hCtrl, szMsg, TEXT("Selected Items"), MB_OK); 
      } 
      else 
         MessageBox(hCtrl, TEXT("None"), TEXT("Selected Items"), MB_OK); 
      if(nRet < 0) 
         return nRet; 
      else 
         return SUCCESS; 
   } 
   else 
      return ERROR_INVALID_PARAMETER; 
} 
Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help