Skip to content

Instantly share code, notes, and snippets.

@tablacus

tablacus/selecttotop.js

Last active Mar 21, 2021
Embed
What would you like to do?
All selected items on top of the list - Tablacus Explorer
const FV = GetFolderView(Ctrl, pt);
const Selected = FV.Items(SVGIO_SELECTION | SVGIO_FLAG_VIEWORDER);
const Progress = api.CreateObject("ProgressDialog");
Progress.StartProgressDialog(te.hwnd, null, 2);
const Name = GetText("Selected items");
try {
FV.SelectItem(null, SVSI_DESELECTOTHERS);
const IconSize = FV.IconSize;
const ViewMode = api.SendMessage(FV.hwndList, LVM_GETVIEW, 0, 0);
if (ViewMode == 1 || ViewMode == 3) {
api.SendMessage(FV.hwndList, LVM_SETVIEW, 4, 0);
}
const FolderFlags = FV.FolderFlags;
FV.FolderFlags = FolderFlags | FWF_AUTOARRANGE;
FV.GroupBy = "System.Null";
const pt2 = api.Memory("POINT");
FV.GetItemPosition(FV.Item(0), pt2);
const nMax = Selected.Count;
Progress.SetLine(1, api.LoadString(hShell32, 50690) + " " + Name, true);
for (let i = 0; !Progress.HasUserCancelled(i, nMax, 2) && i < nMax; ++i) {
FV.SelectAndPositionItem(Selected.Item(nMax - i - 1), SVSI_DESELECT, pt2);
}
FV.SelectItem(Selected, SVSI_SELECT | SVSI_FOCUSED);
api.SendMessage(FV.hwndList, LVM_SETVIEW, ViewMode, 0);
FV.FolderFlags = FolderFlags;
FV.IconSize = IconSize;
} catch (e) { }
Progress.StopProgressDialog();
@tablacus

This comment has been minimized.

Copy link
Owner Author

@tablacus tablacus commented Mar 17, 2021

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment