News:

MultiCommander v16.6 is released!

Main Menu

Get all items and select some of them

Started by ice-man, July 21, 2013, 13:33:36

Previous topic - Next topic

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 ?


Intel i7-6700K - Running on latest Windows 10 64bit Insider Preview

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.

QuoteIFileItemCollection* 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();
(Will add this to the SDK Sample project)