Multi Commander > SDK

Get all items and select some of them

(1/1)

ice-man:
I been playing around a bit with the SDK.

In one of the sample plugins you have an example on how to get all selected items.

But if I want to get all items and then set some of them as selected. How do I do that ?


Mathias (Author):
Use the AM_GETFILESITEMS and AM_SELECTFILEITEMS message

This code will get all items in the current source view and then select every second item.


--- Quote ---IFileItemCollection* pFileItems = m_pAppInterface->CreateFileItemCollection();
IFileItemCollection* pFileItemsSelected = m_pAppInterface->CreateFileItemCollection();
m_pAppInterface->SendMessageToSource( AM_GETFILEITEMS, (WPARAM)pFileItems, MF_ALL);
 
 DWORD nCount = pFileItems->Count();
 for(DWORD n = 0; n < nCount; ++n)
 {
   IFileItem* pItem = pFileItems->GetAt(n);
   if(pItem && n % 2)
  {
     pFileItemsSelected->Add(pItem);
   }
 }

 m_pAppInterface->SendMessageToSource( AM_SELECTFILEITEMS, (WPARAM)pFileItemsSelected, 1); // 0 for Unselect, 1 for Select
 pFileItemsSelected->Release();
 pFileItems->Release();

--- End quote ---
(Will add this to the SDK Sample project)

Navigation

[0] Message Index

Go to full version