I'm writing some code will automate selection of Window Explorer(explorer.exe) items. And I found two methods that might help:
HRESULT SelectItem(
[in] VARIANT *pvfi,
[in] int dwFlags
);
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dd894079(v=vs.85).aspx
HRESULT SelectItemRelative(
[in] int iRelative
);
// from http://msdn.microsoft.com/en-us/library/windows/desktop/bb774966(v=vs.85).aspx
I've tried SelectItemRelative and it works perfectly; next item in explorer is selected when I pass 1 as argument. The method is self-explanatory
Now, I don't quite get SelectItem, it takes a VARIANT and an int. According to MSDN, the int flag tells the method what kind of selection to make, and that's all, no explanation on what VARIANT is.
What should I pass for VARIANT *pvfi?
IShellFolderViewDual is a dual to the (long gone IIRC) IShellFolderView. Some vestigial documentation remains. Someone has been a fan of quantum physics, it seems.
The variant should carry a VT_UNKNOWN pointing to the FolderItem instance of the item you wish to change the selection of. Then, the selection flags are as follows:
SVSI_DESELECT) deselectSVSI_SELECT) selectSVSI_EDIT) put the item in edit modeSVSI_DESELECTOTHERS) deselect all bu the specified itemSVSI_ENSUREVISIBLE) ensure that the item is visible in the view (scrollthe view)SVSI_FOCUSED) give the item the focusFor VARIANT you may pass LPCITEMIDLIST of the item.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With