From ed38f3390bbde1b08b3558a85a0fe7e4d8e34208 Mon Sep 17 00:00:00 2001 From: Gaku Date: Sun, 2 Jul 2017 22:07:57 +0900 Subject: [PATCH] 17.7.2 Adjusted: New file, Rename --- Debug/script/common.js | 96 +++++++++++++----- Debug/script/index.js | 184 +++++++++++++++++----------------- Debug/script/options.html | 6 +- Debug/script/options.js | 2 + TE/Resource.h | 4 +- TE/TE.cpp | 204 ++++++++++++++++++++++++-------------- TE/TE.h | 2 +- 7 files changed, 301 insertions(+), 197 deletions(-) diff --git a/Debug/script/common.js b/Debug/script/common.js index c96511b6..761ddfa3 100644 --- a/Debug/script/common.js +++ b/Debug/script/common.js @@ -35,7 +35,8 @@ g_ = { tidWindowRegistered: null, bWindowRegistered: true, xmlWindow: null, - elAddons: {} + elAddons: {}, + event: {} }; FolderMenu = @@ -167,11 +168,8 @@ AddEvent = function (Name, fn, priority) { if (Name) { Name = Name.replace("Dragleave", "DragLeave"); - if (Name == "ItemPrePaint" && !te.OnItemPrePaint) { - te.OnItemPrePaint = function (Ctrl, pid, nmcd, vcd, plRes) - { - RunEvent3("ItemPrePaint", Ctrl, pid, nmcd, vcd, plRes); - } + if (g_.event[Name] && !te["On" + Name]) { + te["On" + Name] = g_.event[Name]; } if (!eventTE[Name]) { @@ -669,7 +667,7 @@ SaveXml = function (filename, all) item.setAttribute("Top", g_.rcWindow.top); item.setAttribute("Width", g_.rcWindow.right - g_.rcWindow.left); item.setAttribute("Height", g_.rcWindow.bottom - g_.rcWindow.top); - item.setAttribute("CmdShow", api.IsZoomed(te.hwnd) ? SW_SHOWMAXIMIZED : SW_SHOWNOACTIVATE); + item.setAttribute("CmdShow", api.IsZoomed(te.hwnd) ? SW_SHOWMAXIMIZED : api.IsChild(te.hwnd, api.GetFocus()) ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE); root.appendChild(item); } var cTC = te.Ctrls(CTRL_TC); @@ -785,8 +783,7 @@ function SendShortcutKeyFV(Key) CreateTab = function () { - var FV = te.Ctrl(CTRL_FV); - Navigate(HOME_PATH ? HOME_PATH : FV, SBSP_NEWBROWSER); + Navigate(HOME_PATH || te.Ctrl(CTRL_FV), SBSP_NEWBROWSER); } Navigate = function (Path, wFlags) @@ -1043,10 +1040,7 @@ CreateFile = function (path) if (r !== undefined) { return r; } - CreateNew(path, function (strPath) - { - fso.CreateTextFile(strPath).Close(); - }); + CreateNew(path, CreateFile2); } CreateFolder2 = function (path) @@ -1056,6 +1050,52 @@ CreateFolder2 = function (path) } } +CreateFile2 = function (path) +{ + var ext = fso.GetExtensionName(path); + if (ext) { + var s, r = "HKCR\\." + ext + "\\"; + try { + s = wsh.regRead(r); + try { + wsh.RegRead(r + "ShellNew\\"); + } catch (e) { + r += s + "\\"; + wsh.RegRead(r + "\\ShellNew\\"); + } + r += "ShellNew\\"; + var ar = ['Command', 'Data', 'FileName']; + for (var i in ar) { + try { + s = wsh.RegRead(r + ar[i]); + } catch (e) { + continue; + } + if (s) { + if (i == 2) { + r = fso.BuildPath(wsh.SpecialFolders("Templates"), s); + if (!fso.FileExists(r)) { + r = wsh.ExpandEnvironmentStrings("%SystemRoot%\\ShellNew\\") + s; + } + fso.CopyFile(r, path); + SetFileTime(path, null, null, new Date()); + return; + } + if (i == 1) { + var a = fso.CreateTextFile(path); + a.Write(s); + a.Close(); + return; + } + ShellExecute(s.replace("%1", path), null, SW_SHOWNORMAL); + return; + } + } + } catch (e) {} + } + fso.CreateTextFile(path).Close(); +} + FormatDateTime = function (s) { return new Date(s).getTime() > 0 ? (api.GetDateFormat(LOCALE_USER_DEFAULT, 0, s, api.GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE)) + " " + api.GetTimeFormat(LOCALE_USER_DEFAULT, 0, s, api.GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT))) : ""; @@ -1276,12 +1316,9 @@ ExtractMacro = function (Ctrl, s) AddEnv("Selected", function(Ctrl) { var ar = []; - var FV = GetFolderView(Ctrl); - if (FV) { - var Selected = FV.SelectedItems(); - if (Selected) { - for (var i = Selected.Count; i > 0; ar.unshift(api.PathQuoteSpaces(api.GetDisplayNameOf(Selected.Item(--i), SHGDN_FORPARSING)))) { - } + var Selected = GetSelectedItems(Ctrl); + if (Selected) { + for (var i = Selected.Count; i > 0; ar.unshift(api.PathQuoteSpaces(api.GetDisplayNameOf(Selected.Item(--i), SHGDN_FORPARSING)))) { } } return ar.join(" "); @@ -1301,7 +1338,10 @@ AddEnv("TreeSelected", function(Ctrl) { var strSel = ""; if (!Ctrl || Ctrl.Type != CTRL_TV) { - Ctrl = te.Ctrl(CTRL_TV); + var FV = GetFolderView(Ctrl); + if (FV) { + Ctrl = FV.TreeView; + } } if (Ctrl) { strSel = api.PathQuoteSpaces(api.GetDisplayNameOf(Ctrl.SelectedItem, SHGDN_FORADDRESSBAR | SHGDN_FORPARSING)); @@ -2520,7 +2560,7 @@ OpenInExplorer = function (FV) { if (FV) { CancelWindowRegistered(); - ShellExecute(api.PathQuoteSpaces(api.GetDisplayNameOf(FV, SHGDN_FORPARSING)), "Explore", SW_SHOWNORMAL); + ShellExecute([api.PathQuoteSpaces("%SystemRoot%\\explorer.exe"), api.PathQuoteSpaces(api.GetDisplayNameOf(FV, SHGDN_FORPARSING))].join(" "), null, SW_SHOWNORMAL); } } @@ -2932,7 +2972,6 @@ InsertTab = function(e) return true; } - RegEnumKey = function(hKey, Name) { var server = te.GetObject("winmgmts:\\\\.\\root\\default:StdRegProv"); @@ -3111,7 +3150,7 @@ SetSysColor = function (i, color) ShellExecute = function (s, vOperation, nShow, vDir2, pt) { - var arg = api.CommandLineToArgv(s); + var arg = api.CommandLineToArgv(ExtractMacro(te, s)); var s = arg.shift(); var vDir = fso.GetParentFolderName(s) || vDir2; if (pt && vDir.Type) { @@ -3298,8 +3337,7 @@ DeleteTempFolder = function () OpenContains = function (Ctrl, pt) { - var FV = GetFolderView(Ctrl. pt); - var Items = FV.SelectedItems(); + var Items = GetSelectedItems(Ctrl, pt); for (var j in Items) { var Item = Items.Item(j); var path = Item.Path; @@ -3405,4 +3443,12 @@ function SameFolderItems(Items1, Items2) } } return true; +} + +function GetSelectedItems(Ctrl, pt) +{ + var FV = GetFolderView(Ctrl, pt); + if (FV) { + return FV.SelectedItems(); + } } \ No newline at end of file diff --git a/Debug/script/index.js b/Debug/script/index.js index f7c4ff9f..d43ccd88 100644 --- a/Debug/script/index.js +++ b/Debug/script/index.js @@ -642,6 +642,9 @@ te.OnCreate = function (Ctrl) } } api.ShowWindow(te.hwnd, te.CmdShow); + if (te.CmdShow == SW_SHOWNOACTIVATE) { + api.SetWindowPos(te.hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + } te.UnlockUpdate(); setTimeout(function () { @@ -739,11 +742,6 @@ te.OnBeforeNavigate = function (Ctrl, fs, wFlags, Prev) return hr; } -te.OnBeginNavigate = function (Ctrl) -{ - return RunEvent2("BeginNavigate", Ctrl); -} - te.OnNavigateComplete = function (Ctrl) { RunEvent1("NavigateComplete", Ctrl); @@ -751,14 +749,6 @@ te.OnNavigateComplete = function (Ctrl) return S_OK; } -ShowStatusText = function (Ctrl, Text, iPart) -{ - RunEvent1("StatusText", Ctrl, Text, iPart); - return S_OK; -} - -te.OnStatusText = ShowStatusText; - te.OnKeyMessage = function (Ctrl, hwnd, msg, key, keydata) { var hr = RunEvent3("KeyMessage", Ctrl, hwnd, msg, key, keydata); @@ -1094,7 +1084,7 @@ te.OnCommand = function (Ctrl, hwnd, msg, wParam, lParam) } var hr = RunEvent3("Command", Ctrl, hwnd, msg, wParam, lParam); RunEvent1("ConfigChanged", "Config"); - return isFinite(hr) ? hr : S_FALSE; + return hr; } te.OnInvokeCommand = function (ContextMenu, fMask, hwnd, Verb, Parameters, Directory, nShow, dwHotKey, hIcon) @@ -1289,34 +1279,12 @@ te.OnDragLeave = function (Ctrl) return hr; } -te.OnSelectionChanging = function (Ctrl) -{ - var hr = RunEvent3("SelectionChanging", Ctrl); - return isFinite(hr) ? hr : S_OK; -} - te.OnSelectionChanged = function (Ctrl, uChange) { if (Ctrl.Type == CTRL_TC && Ctrl.SelectedIndex >= 0) { ChangeView(Ctrl.Selected); } - var hr = RunEvent3("SelectionChanged", Ctrl, uChange); - return isFinite(hr) ? hr : S_OK; -} - -te.OnViewModeChanged = function (Ctrl) -{ - RunEvent1("ViewModeChanged", Ctrl); -} - -te.OnColumnsChanged = function (Ctrl) -{ - RunEvent1("ColumnsChanged", Ctrl); -} - -te.OnIconSizeChanged = function (Ctrl) -{ - RunEvent1("IconSizeChanged", Ctrl); + return RunEvent3("SelectionChanged", Ctrl, uChange); } te.OnFilterChanged = function (Ctrl) @@ -1410,18 +1378,6 @@ te.OnDefaultCommand = function (Ctrl) return S_OK; } -te.OnItemClick = function (Ctrl, Item, HitTest, Flags) -{ - var hr = RunEvent3("ItemClick", Ctrl, Item, HitTest, Flags); - return isFinite(hr) ? hr : S_FALSE; -} - -te.OnColumnClick = function (Ctrl, iItem) -{ - var hr = RunEvent3("ColumnClick", Ctrl, iItem); - return isFinite(hr) ? hr : S_FALSE; -} - te.OnSystemMessage = function (Ctrl, hwnd, msg, wParam, lParam) { var hr = RunEvent3("SystemMessage", Ctrl, hwnd, msg, wParam, lParam); @@ -1747,7 +1703,68 @@ te.OnVisibleChanged = function (Ctrl) RunEvent1("VisibleChanged", Ctrl); } -te.OnWindowRegistered = function (Ctrl) +te.OnILGetParent = function (FolderItem) +{ + var r = RunEvent4("ILGetParent", FolderItem); + if (r !== undefined) { + return r; + } + var res = IsSearchPath(FolderItem); + if (res) { + return api.PathCreateFromUrl("file:" + res[1]); + } + if (api.ILIsEqual(FolderItem, ssfRESULTSFOLDER)) { + var ar = api.GetDisplayNameOf(FolderItem, SHGDN_FORADDRESSBAR | SHGDN_FORPARSING | SHGDN_FORPARSINGEX).split("\\"); + if (ar.length > 1 && ar.pop()) { + return ar.join("\\"); + } + } +} + +ShowStatusText = function (Ctrl, Text, iPart) +{ + RunEvent1("StatusText", Ctrl, Text, iPart); + return S_OK; +} + +g_.event.StatusText = ShowStatusText; + +g_.event.BeginNavigate = function (Ctrl) +{ + return RunEvent2("BeginNavigate", Ctrl); +} + +g_.event.SelectionChanging = function (Ctrl) +{ + return RunEvent3("SelectionChanging", Ctrl); +} + +g_.event.ViewModeChanged = function (Ctrl) +{ + RunEvent1("ViewModeChanged", Ctrl); +} + +g_.event.ColumnsChanged = function (Ctrl) +{ + RunEvent1("ColumnsChanged", Ctrl); +} + +g_.event.IconSizeChanged = function (Ctrl) +{ + RunEvent1("IconSizeChanged", Ctrl); +} + +g_.event.ItemClick = function (Ctrl, Item, HitTest, Flags) +{ + return RunEvent3("ItemClick", Ctrl, Item, HitTest, Flags); +} + +g_.event.ColumnClick = function (Ctrl, iItem) +{ + return RunEvent3("ColumnClick", Ctrl, iItem); +} + +g_.event.WindowRegistered = function (Ctrl) { if (g_.bWindowRegistered) { RunEvent1("WindowRegistered", Ctrl); @@ -1755,77 +1772,57 @@ te.OnWindowRegistered = function (Ctrl) g_.bWindowRegistered = true; } -te.OnToolTip = function (Ctrl, Index) +g_.event.ToolTip = function (Ctrl, Index) { return RunEvent4("ToolTip", Ctrl, Index); } -te.OnHitTest = function (Ctrl, pt, flags) +g_.event.HitTest = function (Ctrl, pt, flags) { - var hr = RunEvent3("HitTest", Ctrl, pt, flags); - return isFinite(hr) ? hr : -1; + return RunEvent3("HitTest", Ctrl, pt, flags); } -te.OnGetPaneState = function (Ctrl, ep, peps) +g_.event.GetPaneState = function (Ctrl, ep, peps) { - var hr = RunEvent3("GetPaneState", Ctrl, ep, peps); - return isFinite(hr) ? hr : E_NOTIMPL; + return RunEvent3("GetPaneState", Ctrl, ep, peps); } -te.OnTranslatePath = function (Ctrl, Path) +g_.event.TranslatePath = function (Ctrl, Path) { return RunEvent4("TranslatePath", Ctrl, Path); } -te.OnILGetParent = function (FolderItem) -{ - var r = RunEvent4("ILGetParent", FolderItem); - if (r !== undefined) { - return r; - } - var res = IsSearchPath(FolderItem); - if (res) { - return api.PathCreateFromUrl("file:" + res[1]); - } - if (api.ILIsEqual(FolderItem, ssfRESULTSFOLDER)) { - var ar = api.GetDisplayNameOf(FolderItem, SHGDN_FORADDRESSBAR | SHGDN_FORPARSING | SHGDN_FORPARSINGEX).split("\\"); - if (ar.length > 1 && ar.pop()) { - return ar.join("\\"); - } - } -} - -te.OnBeginDrag = function (Ctrl) +g_.event.BeginDrag = function (Ctrl) { return !isFinite(RunEvent3("BeginDrag", Ctrl)); } -te.OnBeforeGetData = function (Ctrl, Items, nMode) +g_.event.BeforeGetData = function (Ctrl, Items, nMode) { return RunEvent2("BeforeGetData", Ctrl, Items, nMode); } -te.OnBeginLabelEdit = function (Ctrl) +g_.event.BeginLabelEdit = function (Ctrl) { return RunEvent4("BeginLabelEdit", Ctrl); } -te.OnEndLabelEdit = function (Ctrl, Name) +g_.event.EndLabelEdit = function (Ctrl, Name) { return RunEvent4("EndLabelEdit", Ctrl, Name); } -te.OnReplacePath = function (FolderItem) +g_.event.ReplacePath = function (FolderItem) { return RunEvent4("ReplacePath", FolderItem, api.GetDisplayNameOf(FolderItem, SHGDN_FORADDRESSBAR | SHGDN_FORPARSING)); } -te.OnSort = function (Ctrl) +g_.event.Sort = function (Ctrl) { return RunEvent1("Sort", Ctrl); } -te.OnFromFile = function (image, file) +g_.event.FromFile = function (image, file) { var alt; var s = fso.BuildPath(fso.GetSpecialFolder(2).Path, "tablacus\\"); @@ -1844,16 +1841,21 @@ te.OnFromFile = function (image, file) return RunEvent3("FromFile", image, file, alt); } -te.OnFromStream = function (image, stream, filename) +g_.event.FromStream = function (image, stream, filename) { return RunEvent3("FromStream", image, stream, filename); } -te.OnEndThread = function (Ctrl) +g_.event.EndThread = function (Ctrl) { return RunEvent1("EndThread", api.GetThreadCount()); } +g_.event.ItemPrePaint = function (Ctrl, pid, nmcd, vcd, plRes) +{ + RunEvent3("ItemPrePaint", Ctrl, pid, nmcd, vcd, plRes); +} + //Tablacus Events GetIconImage = function (Ctrl, BGColor) @@ -2724,11 +2726,7 @@ g_basic = "New Tab": function (Ctrl, pt) { var FV = GetFolderView(Ctrl, pt); - if (HOME_PATH) { - NavigateFV(FV, HOME_PATH, SBSP_NEWBROWSER); - } else { - NavigateFV(FV, null, SBSP_RELATIVE | SBSP_NEWBROWSER); - } + NavigateFV(FV, HOME_PATH || FV, SBSP_NEWBROWSER); }, Lock: function (Ctrl, pt) { @@ -2907,8 +2905,7 @@ g_basic = "New File": CreateNewFile, "Copy Full Path": function (Ctrl, pt) { - var FV = GetFolderView(Ctrl, pt); - var Selected = FV.SelectedItems(); + var Selected = GetSelectedItems(Ctrl, pt); var s = ""; var nCount = Selected.Count; if (nCount) { @@ -3315,7 +3312,7 @@ close()", EscapeUpdateFile(arg.InstalledFolder), GetText("Please wait."), MB_ICO update = s1; s1 = '"'; } - g_.strUpdate = ['"', api.IsWow64Process(api.GetCurrentProcess()) ? wsh.ExpandEnvironmentStrings("%windir%\\Sysnative") : system32, "\\", exe, '" ', s1, update, '"'].join(""); + g_.strUpdate = ['"', api.IsWow64Process(api.GetCurrentProcess()) ? wsh.ExpandEnvironmentStrings("%SystemRoot%\\Sysnative") : system32, "\\", exe, '" ', s1, update, '"'].join(""); DeleteTempFolder = function () { var oExec = wsh.Exec(g_.strUpdate); @@ -3400,6 +3397,7 @@ if (!te.Data) { { te.UnlockUpdate(); setTimeout(Resize, 99); + window.focus(); }, 500); } diff --git a/Debug/script/options.html b/Debug/script/options.html index d8ad8c32..83f44bf3 100644 --- a/Debug/script/options.html +++ b/Debug/script/options.html @@ -345,7 +345,7 @@
- +
@@ -469,7 +469,7 @@
- +
(*)Windows Vista @@ -619,7 +619,7 @@

- +
(*X)Windows XP diff --git a/Debug/script/options.js b/Debug/script/options.js index fb894e3f..8bfe584a 100644 --- a/Debug/script/options.js +++ b/Debug/script/options.js @@ -1349,8 +1349,10 @@ InitOptions = function () if (g_nResult == 1) { w.TEOk(); } + w.close(); } catch (e) {} } + g_.elAddons = {}; g_bChanged |= g_Chg.Addons || te.Data.bErrorAddons || g_Chg.Menus || g_Chg.Tab || g_Chg.Tree || g_Chg.View; SaveAddons(); SetOptions(Apply); diff --git a/TE/Resource.h b/TE/Resource.h index 78ecc187..19c32603 100644 --- a/TE/Resource.h +++ b/TE/Resource.h @@ -10,5 +10,5 @@ #define STRING(str) STRING2(str) #define STRING2(str) #str #define VER_Y 17 -#define VER_M 6 -#define VER_D 20 +#define VER_M 7 +#define VER_D 2 diff --git a/TE/TE.cpp b/TE/TE.cpp index 432e51a6..42004dca 100644 --- a/TE/TE.cpp +++ b/TE/TE.cpp @@ -746,6 +746,20 @@ TEmethod tesMENUINFO[] = { 0, NULL } }; +TEmethod tesGUITHREADINFO[] = +{ + { (VT_I4 << TE_VT) + offsetof(GUITHREADINFO, cbSize), "cbSize" }, + { (VT_I4 << TE_VT) + offsetof(GUITHREADINFO, flags), "flags" }, + { (VT_PTR << TE_VT) + offsetof(GUITHREADINFO, hwndActive), "hwndActive" }, + { (VT_PTR << TE_VT) + offsetof(GUITHREADINFO, hwndFocus), "hwndFocus" }, + { (VT_PTR << TE_VT) + offsetof(GUITHREADINFO, hwndCapture), "hwndCapture" }, + { (VT_PTR << TE_VT) + offsetof(GUITHREADINFO, hwndMenuOwner), "hwndMenuOwner" }, + { (VT_PTR << TE_VT) + offsetof(GUITHREADINFO, hwndMoveSize), "hwndMoveSize" }, + { (VT_PTR << TE_VT) + offsetof(GUITHREADINFO, hwndCaret), "hwndCaret" }, + { (VT_CARRAY << TE_VT) + offsetof(GUITHREADINFO, hwndCaret), "rcCaret" }, + { 0, NULL } +}; + TEStruct pTEStructs[] = { { sizeof(BITMAP), "BITMAP", tesBITMAP }, { sizeof(BSTR), "BSTR", tesNULL }, @@ -761,6 +775,7 @@ TEStruct pTEStructs[] = { { sizeof(FINDREPLACE), "FINDREPLACE", tesFINDREPLACE }, { sizeof(FOLDERSETTINGS), "FOLDERSETTINGS", tesFOLDERSETTINGS }, { sizeof(GUID), "GUID", tesNULL }, + { sizeof(GUITHREADINFO), "GUITHREADINFO", tesGUITHREADINFO }, { sizeof(HANDLE), "HANDLE", tesNULL }, { sizeof(HDITEM), "HDITEM", tesHDITEM }, { sizeof(ICONINFO), "ICONINFO", tesICONINFO }, @@ -3998,6 +4013,12 @@ VOID teSetIDList(VARIANT *pv, LPITEMIDLIST pidl) } } +VOID teSetIDListRelease(VARIANT *pv, LPITEMIDLIST *ppidl) +{ + teSetIDList(pv, *ppidl); + teILFreeClear(ppidl); +} + int teGetObjectLength(IDispatch *pdisp) { VARIANT v; @@ -4417,9 +4438,20 @@ VOID GetpDataFromVariant(UCHAR **ppc, int *pnLen, VARIANT *pv) *pnLen = 0; } -HRESULT Invoke4(IDispatch *pdisp, VARIANT *pvResult, int nArgs, VARIANTARG *pvArgs) +VOID Invoke4(IDispatch *pdisp, VARIANT *pvResult, int nArgs, VARIANTARG *pvArgs) { - return Invoke5(pdisp, DISPID_VALUE, DISPATCH_METHOD, pvResult, nArgs, pvArgs); + Invoke5(pdisp, DISPID_VALUE, DISPATCH_METHOD, pvResult, nArgs, pvArgs); +} + +VOID teCustomDrawItemPrePaint(PVOID pCtrl, LPITEMIDLIST pidl, LPNMCUSTOMDRAW lpnmcd, PVOID pvcd, LRESULT *lpres) +{ + VARIANTARG *pv = GetNewVARIANT(5); + teSetObject(&pv[4], pCtrl); + teSetIDListRelease(&pv[3], &pidl); + teSetObjectRelease(&pv[2], new CteMemory(sizeof(NMCUSTOMDRAW), lpnmcd, 1, L"NMCUSTOMDRAW")); + teSetObjectRelease(&pv[1], pvcd); + teSetObjectRelease(&pv[0], new CteMemory(sizeof(HANDLE), lpres, 1, L"HANDLE")); + Invoke4(g_pOnFunc[TE_OnItemPrePaint], NULL, 5, pv); } HRESULT ParseScript(LPOLESTR lpScript, LPOLESTR lpLang, VARIANT *pv, IDispatch **ppdisp, EXCEPINFO *pExcepInfo) @@ -4531,7 +4563,10 @@ HRESULT DoFunc(int nFunc, PVOID pObj, HRESULT hr) { VARIANT vResult; VariantInit(&vResult); - return SUCCEEDED(DoFunc1(nFunc, pObj, &vResult)) ? GetIntFromVariantClear(&vResult) : hr; + if (SUCCEEDED(DoFunc1(nFunc, pObj, &vResult)) && vResult.vt != VT_EMPTY) { + hr = GetIntFromVariantClear(&vResult); + } + return hr; } VOID teSetProgress(IProgressDialog *ppd, int nCurrent, int nCount) @@ -4578,12 +4613,11 @@ static void threadAddItems(void *args) pidl = teSHSimpleIDListFromPath(pAddItems->pv[1].bstrVal, FALSE); } if (pidl) { - VariantClear(&pAddItems->pv[1]); - teSetIDList(&pAddItems->pv[1], pidl); if (SHGetPathFromIDList(pidl, pszMsg)) { ppd->SetLine(2, PathFindFileName(pszMsg), TRUE, NULL); } - teCoTaskMemFree(pidl); + VariantClear(&pAddItems->pv[1]); + teSetIDListRelease(&pAddItems->pv[1], &pidl); if (Invoke5(pSB, 0x10000501, DISPATCH_METHOD, NULL, -2, pAddItems->pv) == E_ACCESSDENIED) { break; } @@ -4720,7 +4754,9 @@ LONG_PTR DoHitTest(PVOID pObj, POINT pt, UINT flags) pstPt->Release(); teSetLong(&pv[0], flags); Invoke4(g_pOnFunc[TE_OnHitTest], &vResult, 3, pv); - return GetPtrFromVariantClear(&vResult); + if (vResult.vt != VT_EMPTY) { + return GetPtrFromVariantClear(&vResult); + } } return -1; } @@ -4743,9 +4779,8 @@ HRESULT DragSub(int nFunc, PVOID pObj, CteFolderItems *pDragItems, PDWORD pgrfKe pstPt->SetPoint(pt.x, pt.y); teSetObjectRelease(&pv[1], pstPt); teSetObjectRelease(&pv[0], new CteMemory(sizeof(int), pdwEffect, 1, L"DWORD")); - if SUCCEEDED(Invoke4(g_pOnFunc[nFunc], &vResult, 5, pv)) { - hr = GetIntFromVariant(&vResult); - } + Invoke4(g_pOnFunc[nFunc], &vResult, 5, pv); + hr = GetIntFromVariant(&vResult); } } catch(...) {} ::InterlockedDecrement(&g_nProcDrag); @@ -4775,7 +4810,8 @@ HRESULT MessageSub(int nFunc, PVOID pObj, MSG *pMsg, HRESULT hrDefault) teSetLong(&pv[2], pMsg->message); teSetPtr(&pv[1], pMsg->wParam); teSetPtr(&pv[0], pMsg->lParam); - if SUCCEEDED(Invoke4(g_pOnFunc[nFunc], &vResult, 5, pv)) { + Invoke4(g_pOnFunc[nFunc], &vResult, 5, pv); + if (vResult.vt != VT_EMPTY) { return GetIntFromVariantClear(&vResult); } } @@ -4807,8 +4843,8 @@ HRESULT MessageSubPt(int nFunc, PVOID pObj, MSG *pMsg) CteMemory *pstPt = new CteMemory(2 * sizeof(int), NULL, 1, L"POINT"); pstPt->SetPoint(pMsg->pt.x, pMsg->pt.y); teSetObjectRelease(&pv[0], pstPt); - - if SUCCEEDED(Invoke4(g_pOnFunc[nFunc], &vResult, 5, pv)) { + Invoke4(g_pOnFunc[nFunc], &vResult, 5, pv); + if (vResult.vt != VT_EMPTY) { return GetIntFromVariantClear(&vResult); } } @@ -5045,28 +5081,23 @@ LRESULT CALLBACK TETVProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } if (msg == WM_NOTIFY) { LPNMTVCUSTOMDRAW lptvcd = (LPNMTVCUSTOMDRAW)lParam; -/// Color +/// Custom Draw if (lptvcd->nmcd.hdr.code == NM_CUSTOMDRAW) { if (lptvcd->nmcd.dwDrawStage == CDDS_PREPAINT) { return CDRF_NOTIFYITEMDRAW; } if (lptvcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) { LONG_PTR lRes = CDRF_DODEFAULT; - if (g_pOnFunc[TE_OnItemPrePaint] && !(lptvcd->nmcd.uItemState & CDIS_SELECTED)) { - VARIANTARG *pv = GetNewVARIANT(5); - teSetObject(&pv[4], pTV); -/*// + if (g_pOnFunc[TE_OnItemPrePaint]) { + LPITEMIDLIST pidl = NULL; if (pTV->m_pShellNameSpace && (lptvcd->nmcd.uItemState & CDIS_SELECTED)) { IDispatch *pid; if (pTV->m_pShellNameSpace->get_SelectedItem(&pid) == S_OK) { - teSetObjectRelease(&pv[3], pid); + teGetIDListFromObject(pid, &pidl); + pid->Release(); } } -*/// - teSetObjectRelease(&pv[2], new CteMemory(sizeof(NMCUSTOMDRAW), &lptvcd->nmcd, 1, L"NMCUSTOMDRAW")); - teSetObjectRelease(&pv[1], new CteMemory(sizeof(NMTVCUSTOMDRAW), lptvcd, 1, L"NMTVCUSTOMDRAW")); - teSetObjectRelease(&pv[0], new CteMemory(sizeof(HANDLE), &lRes, 1, L"HANDLE")); - Invoke4(g_pOnFunc[TE_OnItemPrePaint], NULL, 5, pv); + teCustomDrawItemPrePaint(pTV, NULL, &lptvcd->nmcd, new CteMemory(sizeof(NMLVCUSTOMDRAW), lptvcd, 1, L"NMTVCUSTOMDRAW"), &lRes); } return lRes; } @@ -5227,6 +5258,26 @@ LRESULT CALLBACK TELVProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return lResult; } } +#ifdef _USE_ONGETICON + // There are obstacles (Icon replace) + if (lpDispInfo->item.mask & LVIF_IMAGE && g_pOnFunc[TE_OnGetIcon]) { + lResult = CallWindowProc((WNDPROC)pSB->m_DefProc, hwnd, msg, wParam, lParam); + IFolderView *pFV; + LPITEMIDLIST pidl; + if SUCCEEDED(pSB->m_pShellView->QueryInterface(IID_PPV_ARGS(&pFV))) { + if SUCCEEDED(pFV->Item(lpDispInfo->item.iItem, &pidl)) { + VARIANTARG *pv = GetNewVARIANT(3); + teSetObject(&pv[2], pSB); + teSetIDListRelease(&pv[1], &pidl); + teSetObjectRelease(&pv[0], new CteMemory(sizeof(LVITEM), &lpDispInfo->item, 1, L"LVITEM")); + Invoke4(g_pOnFunc[TE_OnGetIcon], NULL, 3, pv); + } + pFV->Release(); + } + return lResult; + } + //end +#endif } else if (((LPNMHDR)lParam)->code == LVN_COLUMNCLICK) { if (g_pOnFunc[TE_OnColumnClick]) { LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lParam; @@ -5243,8 +5294,10 @@ LRESULT CALLBACK TELVProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) VARIANT vResult; VariantInit(&vResult); Invoke4(g_pOnFunc[TE_OnColumnClick], &vResult, 2, pv); - if (!GetIntFromVariantClear(&vResult)) { - return 1; + if (vResult.vt != VT_EMPTY) { + if (!GetIntFromVariantClear(&vResult)) { + return 1; + } } } } @@ -5275,6 +5328,13 @@ LRESULT CALLBACK TELVProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) lpDispInfo->item.pszText[0] = NULL; } } + if (lpDispInfo->item.pszText[0] == '.' && !StrChr(&lpDispInfo->item.pszText[1], '.')) { + int i = lstrlen(lpDispInfo->item.pszText); + if (i > 1 && i < lpDispInfo->item.cchTextMax - 1) { + lpDispInfo->item.pszText[i++] = '.'; + lpDispInfo->item.pszText[i] = NULL; + } + } #ifdef _FIXWIN10IPBUG1 SetTimer(pSB->m_hwnd, 1, 64, teTimerProcFixWin10IPBug1); #endif @@ -5296,33 +5356,27 @@ LRESULT CALLBACK TELVProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } else if (((LPNMHDR)lParam)->code == HDN_ITEMCHANGED) { pSB->SetLVSettings(); } -/// Color - if (g_pOnFunc[TE_OnItemPrePaint] && pSB->m_pShellView) { - LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam; - if (lplvcd->nmcd.hdr.code == NM_CUSTOMDRAW) { - if (lplvcd->nmcd.dwDrawStage == CDDS_PREPAINT) { - return CDRF_NOTIFYITEMDRAW; - } - if (lplvcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) { - LRESULT lRes = CDRF_DODEFAULT; - IFolderView *pFV; - if SUCCEEDED(pSB->m_pShellView->QueryInterface(IID_PPV_ARGS(&pFV))) { - LPITEMIDLIST pidl; - if SUCCEEDED(pFV->Item((int)lplvcd->nmcd.dwItemSpec , &pidl)) { - LPITEMIDLIST pidlFull = ILCombine(pSB->m_pidl, pidl); - VARIANTARG *pv = GetNewVARIANT(5); - teSetObject(&pv[4], pSB); - teSetIDList(&pv[3], pidlFull); - teCoTaskMemFree(pidlFull); - teCoTaskMemFree(pidl); - teSetObjectRelease(&pv[2], new CteMemory(sizeof(NMCUSTOMDRAW), &lplvcd->nmcd, 1, L"NMCUSTOMDRAW")); - teSetObjectRelease(&pv[1], new CteMemory(sizeof(NMLVCUSTOMDRAW), lplvcd, 1, L"NMLVCUSTOMDRAW")); - teSetObjectRelease(&pv[0], new CteMemory(sizeof(HANDLE), &lRes, 1, L"HANDLE")); - Invoke4(g_pOnFunc[TE_OnItemPrePaint], NULL, 5, pv); +/// Custom Draw + if (pSB->m_pShellView) { + if (g_pOnFunc[TE_OnItemPrePaint]) { + LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam; + if (lplvcd->nmcd.hdr.code == NM_CUSTOMDRAW) { + if (lplvcd->nmcd.dwDrawStage == CDDS_PREPAINT) { + return CDRF_NOTIFYITEMDRAW; + } + if (lplvcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) { + LRESULT lRes = CDRF_DODEFAULT; + IFolderView *pFV; + if SUCCEEDED(pSB->m_pShellView->QueryInterface(IID_PPV_ARGS(&pFV))) { + LPITEMIDLIST pidl; + if SUCCEEDED(pFV->Item((int)lplvcd->nmcd.dwItemSpec, &pidl)) { + teCustomDrawItemPrePaint(pSB, ILCombine(pSB->m_pidl, pidl), &lplvcd->nmcd, new CteMemory(sizeof(NMLVCUSTOMDRAW), lplvcd, 1, L"NMLVCUSTOMDRAW"), &lRes); + teCoTaskMemFree(pidl); + } + pFV->Release(); } - pFV->Release(); + return lRes; } - return lRes; } } } @@ -8515,8 +8569,7 @@ VOID teApiSHSimpleIDListFromPath(int nArg, teParam *param, DISPPARAMS *pDispPara } } } - teSetIDList(pVarResult, pidl); - teCoTaskMemFree(pidl); + teSetIDListRelease(pVarResult, &pidl); } } @@ -8717,6 +8770,16 @@ VOID teApiFormatMessage(int nArg, teParam *param, DISPPARAMS *pDispParams, VARIA } } +VOID teApiGetGUIThreadInfo(int nArg, teParam *param, DISPPARAMS *pDispParams, VARIANT *pVarResult) +{ + teSetBool(pVarResult, GetGUIThreadInfo(param[0].dword, param[1].pgui)); +} + +VOID teApiCreateSolidBrush(int nArg, teParam *param, DISPPARAMS *pDispParams, VARIANT *pVarResult) +{ + teSetPtr(pVarResult, CreateSolidBrush(param[0].colorref)); +} + /* VOID teApi(int nArg, teParam *param, DISPPARAMS *pDispParams, VARIANT *pVarResult) { @@ -9031,6 +9094,8 @@ TEDispatchApi dispAPI[] = { {11, -1, -1, -1, "StretchBlt", teApiStretchBlt }, {11, -1, -1, -1, "TransparentBlt", teApiTransparentBlt }, { 2, 0, 1, 2, "FormatMessage", teApiFormatMessage }, + { 2, -1, -1, -1, "GetGUIThreadInfo", teApiGetGUIThreadInfo }, + { 1, -1, -1, -1, "CreateSolidBrush", teApiCreateSolidBrush }, // { 0, -1, -1, -1, "", teApi }, // { 0, -1, -1, -1, "Test", teApiTest }, }; @@ -12995,8 +13060,7 @@ STDMETHODIMP CteShellBrowser::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid LPITEMIDLIST pidl; if SUCCEEDED(pFV->Item(i, &pidl)) { LPITEMIDLIST pidlFull = ILCombine(m_pidl, pidl); - teSetIDList(pVarResult, pidlFull); - teCoTaskMemFree(pidlFull); + teSetIDListRelease(pVarResult, &pidlFull); teCoTaskMemFree(pidl); } pFV->Release(); @@ -13024,8 +13088,7 @@ STDMETHODIMP CteShellBrowser::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid LPITEMIDLIST pidl; if SUCCEEDED(pFV->Item(GetIntFromVariant(&pDispParams->rgvarg[nArg]), &pidl)) { LPITEMIDLIST pidlFull = ILCombine(m_pidl, pidl); - teSetIDList(pVarResult, pidlFull); - teCoTaskMemFree(pidlFull); + teSetIDListRelease(pVarResult, &pidlFull); teCoTaskMemFree(pidl); } pFV->Release(); @@ -14235,7 +14298,8 @@ STDMETHODIMP CteShellBrowser::GetPaneState(REFEXPLORERPANE ep, EXPLORERPANESTATE } VARIANT vResult; VariantInit(&vResult); - if SUCCEEDED(Invoke4(g_pOnFunc[TE_OnGetPaneState], &vResult, 3, pv)) { + Invoke4(g_pOnFunc[TE_OnGetPaneState], &vResult, 3, pv); + if (vResult.vt != VT_EMPTY) { return GetIntFromVariantClear(&vResult); } } @@ -19708,7 +19772,9 @@ STDMETHODIMP CteTreeView::OnItemClick(IShellItem *psi, NSTCEHITTEST nstceHitTest teSetLong(&pv[0], nsctsFlags); VariantInit(&vResult); Invoke4(g_pOnFunc[TE_OnItemClick], &vResult, 4, pv); - return GetIntFromVariantClear(&vResult); + if (vResult.vt != VT_EMPTY) { + return GetIntFromVariantClear(&vResult); + } } return S_FALSE; } @@ -19848,7 +19914,7 @@ STDMETHODIMP CteTreeView::OnGetDefaultIconIndex(IShellItem *psi, int *piDefaultI //INameSpaceTreeControlCustomDraw STDMETHODIMP CteTreeView::PrePaint(HDC hdc, RECT *prc, LRESULT *plres) { - *plres = CDRF_NOTIFYITEMDRAW; + *plres = g_pOnFunc[TE_OnItemPrePaint] ? CDRF_NOTIFYITEMDRAW : CDRF_DODEFAULT; return S_OK; } @@ -19859,19 +19925,11 @@ STDMETHODIMP CteTreeView::PostPaint(HDC hdc, RECT *prc) STDMETHODIMP CteTreeView::ItemPrePaint(HDC hdc, RECT *prc, NSTCCUSTOMDRAW *pnstccdItem, COLORREF *pclrText, COLORREF *pclrTextBk, LRESULT *plres) { - if (g_pOnFunc[TE_OnItemPrePaint] && !(pnstccdItem->uItemState & CDIS_SELECTED)) { - NMTVCUSTOMDRAW tvcd = { { { 0 }, 0, hdc, *prc, 0, pnstccdItem->uItemState }, *pclrText, *pclrTextBk, pnstccdItem->iLevel }; - VARIANTARG *pv = GetNewVARIANT(5); - teSetObject(&pv[4], this); - LPITEMIDLIST pidl; - if (teGetIDListFromObject(pnstccdItem->psi, &pidl)) { - teSetIDList(&pv[3], pidl); - CoTaskMemFree(pidl); - } - teSetObjectRelease(&pv[2], new CteMemory(sizeof(NMCUSTOMDRAW), &tvcd.nmcd, 1, L"NMCUSTOMDRAW")); - teSetObjectRelease(&pv[1], new CteMemory(sizeof(NMTVCUSTOMDRAW), &tvcd, 1, L"NMTVCUSTOMDRAW")); - teSetObjectRelease(&pv[0], new CteMemory(sizeof(HANDLE), plres, 1, L"HANDLE")); - Invoke4(g_pOnFunc[TE_OnItemPrePaint], NULL, 5, pv); + if (g_pOnFunc[TE_OnItemPrePaint]) { + NMTVCUSTOMDRAW tvcd = { { { 0, 0, NM_CUSTOMDRAW }, CDDS_ITEMPREPAINT, hdc, *prc, 0, pnstccdItem->uItemState }, *pclrText, *pclrTextBk, pnstccdItem->iLevel }; + LPITEMIDLIST pidl = NULL; + teGetIDListFromObject(pnstccdItem->psi, &pidl); + teCustomDrawItemPrePaint(this, pidl, &tvcd.nmcd, new CteMemory(sizeof(NMTVCUSTOMDRAW), &tvcd, 1, L"NMTVCUSTOMDRAW"), plres); *pclrText = tvcd.clrText; *pclrTextBk = tvcd.clrTextBk; } diff --git a/TE/TE.h b/TE/TE.h index 52edacd2..55f84fcf 100644 --- a/TE/TE.h +++ b/TE/TE.h @@ -167,6 +167,7 @@ union teParam LPCMENUITEMINFO lpcmenuiteminfo; LPOSVERSIONINFO lposversioninfo; PRTL_OSVERSIONINFOEXW prtl_osversioninfoexw; + PGUITHREADINFO pgui; ATOM atom; ASSOCF assocf; @@ -318,7 +319,6 @@ typedef VOID (__cdecl * LPFNDispatchAPI)(int nArg, teParam *param, DISPPARAMS *p #define TE_OnFromStream 47 #define TE_OnEndThread 48 #define Count_OnFunc 49 - #define SB_TotalFileSize 0 #define SB_OnIncludeObject 1 #define SB_AltSelectedItems 2