private IntPtr CallbackGetMsgProc(int nCode, IntPtr wParam, IntPtr lParam) { if(nCode >= 0) { MSG msg = (MSG)Marshal.PtrToStructure(lParam, typeof(MSG)); try { if(QTUtility.IsXP) { if(msg.message == WM.CLOSE) { if(iSequential_WM_CLOSE > 0) { Marshal.StructureToPtr(new MSG(), lParam, false); return PInvoke.CallNextHookEx(hHook_Msg, nCode, wParam, lParam); } iSequential_WM_CLOSE++; } else { iSequential_WM_CLOSE = 0; } } if(msg.message == WM_NEWTREECONTROL) { object obj = Marshal.GetObjectForIUnknown(msg.wParam); try { if(obj != null) { IOleWindow window = obj as IOleWindow; if(window != null) { IntPtr hwnd; window.GetWindow(out hwnd); if(hwnd != IntPtr.Zero && PInvoke.IsChild(ExplorerHandle, hwnd)) { hwnd = WindowUtils.FindChildWindow(hwnd, child => PInvoke.GetClassName(child) == "SysTreeView32"); if(hwnd != IntPtr.Zero) { INameSpaceTreeControl control = obj as INameSpaceTreeControl; if(control != null) { if(treeViewWrapper != null) { treeViewWrapper.Dispose(); } treeViewWrapper = new TreeViewWrapper(hwnd, control); treeViewWrapper.TreeViewMiddleClicked += TreeView_MiddleClicked; obj = null; } } } } } } finally { if(obj != null) { Marshal.ReleaseComObject(obj); } } return PInvoke.CallNextHookEx(hHook_Msg, nCode, wParam, lParam); } else if(msg.message == WM_LISTREFRESHED) { HandleF5(); return PInvoke.CallNextHookEx(hHook_Msg, nCode, wParam, lParam); } switch(msg.message) { case WM.LBUTTONDOWN: case WM.LBUTTONUP: if((QTUtility.IsXP && !QTUtility.CheckConfig(Settings.NoMidClickTree)) && ((((int)((long)msg.wParam)) & 4) != 0)) { HandleLBUTTON_Tree(msg, msg.message == 0x201); } break; case WM.MBUTTONUP: if(QTUtility.IsXP && !Explorer.Busy && !QTUtility.CheckConfig(Settings.NoMidClickTree)) { Handle_MButtonUp_Tree(msg); } break; case WM.CLOSE: if(QTUtility.IsXP) { if((msg.hwnd == ExplorerHandle) && HandleCLOSE(msg.lParam)) { Marshal.StructureToPtr(new MSG(), lParam, false); } break; } if(msg.hwnd == WindowUtils.GetShellTabWindowClass(ExplorerHandle)) { try { bool flag = tabControl1.TabCount == 1; string currentPath = ((QTabItem)tabControl1.SelectedTab).CurrentPath; if(!Directory.Exists(currentPath) && currentPath.Length > 3 /* && currentPath.Substring(1, 2) == @":\" */ ) { if(flag) { WindowUtils.CloseExplorer(ExplorerHandle, 2); } else { CloseTab((QTabItem)tabControl1.SelectedTab, true); } } } catch { } Marshal.StructureToPtr(new MSG(), lParam, false); } break; case WM.COMMAND: if(QTUtility.IsXP) { int num = ((int)((long)msg.wParam)) & 0xffff; if(num == 0xa021) { WindowUtils.CloseExplorer(ExplorerHandle, 3); Marshal.StructureToPtr(new MSG(), lParam, false); } } break; } } catch(Exception ex) { QTUtility2.MakeErrorLog(ex, String.Format("Message: {0:x4}", msg.message)); } } return PInvoke.CallNextHookEx(hHook_Msg, nCode, wParam, lParam); }
public override void CloseDW(uint dwReserved) { try { if(treeViewWrapper != null) { treeViewWrapper.Dispose(); treeViewWrapper = null; } if(listViewManager != null) { listViewManager.Dispose(); listViewManager = null; } if(subDirTip_Tab != null) { subDirTip_Tab.Dispose(); subDirTip_Tab = null; } if(IsShown) { if(pluginManager != null) { pluginManager.Close(false); pluginManager = null; } if(hHook_Key != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_Key); hHook_Key = IntPtr.Zero; } if(hHook_Mouse != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_Mouse); hHook_Mouse = IntPtr.Zero; } if(hHook_Msg != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_Msg); hHook_Msg = IntPtr.Zero; } if(explorerController != null) { explorerController.ReleaseHandle(); explorerController = null; } if(rebarController != null) { rebarController.ReleaseHandle(); rebarController = null; } if(!QTUtility.IsXP && (travelBtnController != null)) { travelBtnController.ReleaseHandle(); travelBtnController = null; } if(dicNotifyIcon != null) { dicNotifyIcon.Remove(ExplorerHandle); } if((hwndNotifyIconParent == ExplorerHandle) && (notifyIcon != null)) { notifyIcon.Dispose(); notifyIcon = null; contextMenuNotifyIcon.Dispose(); contextMenuNotifyIcon = null; hwndNotifyIconParent = IntPtr.Zero; if(dicNotifyIcon.Count > 0) { foreach(IntPtr ptr in dicNotifyIcon.Keys) { IntPtr tabBarHandle = QTUtility.instanceManager.GetTabBarHandle(ptr); if(1 == ((int)QTUtility2.SendCOPYDATASTRUCT(tabBarHandle, (IntPtr)0x30, "createNI", IntPtr.Zero))) { break; } } } } using(RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Quizo\QTTabBar")) { if(!QTUtility.CheckConfig(Settings.NoHistory)) { foreach(QTabItem item in tabControl1.TabPages) { AddToHistory(item); } QTUtility.SaveRecentlyClosed(key); } if(!QTUtility.CheckConfig(Settings.NoRecentFiles) && QTUtility.CheckConfig(Settings.AllRecentFiles)) { QTUtility.SaveRecentFiles(key); } string[] list = (from QTabItem item2 in tabControl1.TabPages where item2.TabLocked select item2.CurrentPath).ToArray(); QTUtility2.WriteRegBinary(list, "TabsLocked", key); key.SetValue("StartUpGroups", QTUtility.StartUpGroupList.StringJoin(";")); if(QTUtility.instanceManager.RemoveInstance(ExplorerHandle, this)) { QTUtility.instanceManager.NextInstanceExists(); QTUtility2.WriteRegHandle("Handle", key, QTUtility.instanceManager.CurrentHandle); } if(QTUtility.CheckConfig(Settings.SaveTransparency)) { if(0x80000 != ((int)PInvoke.Ptr_OP_AND(PInvoke.GetWindowLongPtr(ExplorerHandle, -20), 0x80000))) { QTUtility.WindowAlpha = 0xff; } else { byte num; int num2; int num3; if(PInvoke.GetLayeredWindowAttributes(ExplorerHandle, out num2, out num, out num3)) { QTUtility.WindowAlpha = num; } else { QTUtility.WindowAlpha = 0xff; } } key.SetValue("WindowAlpha", QTUtility.WindowAlpha); } IDLWrapper.SaveCache(key); } if((md5Form != null) && !md5Form.InvokeRequired) { md5Form.SaveMD5FormStat(); md5Form.Dispose(); md5Form = null; } Cursor = Cursors.Default; if((curTabDrag != null) && (curTabDrag != Cursors.Default)) { PInvoke.DestroyIcon(curTabDrag.Handle); GC.SuppressFinalize(curTabDrag); curTabDrag = null; } if((curTabCloning != null) && (curTabCloning != Cursors.Default)) { PInvoke.DestroyIcon(curTabCloning.Handle); GC.SuppressFinalize(curTabCloning); curTabCloning = null; } if(dropTargetWrapper != null) { dropTargetWrapper.Dispose(); dropTargetWrapper = null; } if((optionsDialog != null) && fOptionDialogCreated) { fOptionDialogCreated = false; try { optionsDialog.Invoke(new MethodInvoker(odCallback_Close)); } catch(Exception exception) { QTUtility2.MakeErrorLog(exception, "optionDialogDisposing"); } } if(tabSwitcher != null) { tabSwitcher.Dispose(); tabSwitcher = null; } } QTUtility.InstancesCount--; if(TravelLog != null) { Marshal.FinalReleaseComObject(TravelLog); TravelLog = null; } if(iContextMenu2 != null) { Marshal.FinalReleaseComObject(iContextMenu2); iContextMenu2 = null; } if(ShellBrowser != null) { ShellBrowser.Dispose(); ShellBrowser = null; } foreach(ITravelLogEntry entry in LogEntryDic.Values) { if(entry != null) { Marshal.FinalReleaseComObject(entry); } } LogEntryDic.Clear(); if(bmpRebar != null) { bmpRebar.Dispose(); bmpRebar = null; } if(textureBrushRebar != null) { textureBrushRebar.Dispose(); textureBrushRebar = null; } fFinalRelease = true; base.CloseDW(dwReserved); } catch(Exception exception2) { QTUtility2.MakeErrorLog(exception2, "tabbar closing"); } }
public override void CloseDW(uint dwReserved) { try { if(treeViewWrapper != null) { treeViewWrapper.Dispose(); treeViewWrapper = null; } if(listViewManager != null) { listViewManager.Dispose(); listViewManager = null; } if(subDirTip_Tab != null) { subDirTip_Tab.Dispose(); subDirTip_Tab = null; } if(IsShown) { if(pluginServer != null) { pluginServer.Dispose(); pluginServer = null; } if(hHook_Key != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_Key); hHook_Key = IntPtr.Zero; } if(hHook_Mouse != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_Mouse); hHook_Mouse = IntPtr.Zero; } if(hHook_Msg != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_Msg); hHook_Msg = IntPtr.Zero; } if(explorerController != null) { explorerController.ReleaseHandle(); explorerController = null; } if(rebarController != null) { rebarController.Dispose(); rebarController = null; } if(!QTUtility.IsXP && (travelBtnController != null)) { travelBtnController.ReleaseHandle(); travelBtnController = null; } InstanceManager.RemoveFromTrayIcon(Handle); // TODO: check this using(RegistryKey key = Registry.CurrentUser.CreateSubKey(RegConst.Root)) { if(Config.Misc.KeepHistory) { foreach(QTabItem item in tabControl1.TabPages) { AddToHistory(item); } QTUtility.SaveRecentlyClosed(key); } if(Config.Misc.KeepRecentFiles) { QTUtility.SaveRecentFiles(key); } string[] list = (from QTabItem item2 in tabControl1.TabPages where item2.TabLocked select item2.CurrentPath).ToArray(); QTUtility2.WriteRegBinary(list, "TabsLocked", key); InstanceManager.UnregisterTabBar(); if(0x80000 != ((int)PInvoke.Ptr_OP_AND(PInvoke.GetWindowLongPtr(ExplorerHandle, -20), 0x80000))) { QTUtility.WindowAlpha = 0xff; } else { byte num; int num2; int num3; if(PInvoke.GetLayeredWindowAttributes(ExplorerHandle, out num2, out num, out num3)) { QTUtility.WindowAlpha = num; } else { QTUtility.WindowAlpha = 0xff; } } key.SetValue("WindowAlpha", QTUtility.WindowAlpha); IDLWrapper.SaveCache(key); } if((md5Form != null) && !md5Form.InvokeRequired) { md5Form.SaveMD5FormStat(); md5Form.Dispose(); md5Form = null; } Cursor = Cursors.Default; if((curTabDrag != null) && (curTabDrag != Cursors.Default)) { PInvoke.DestroyIcon(curTabDrag.Handle); GC.SuppressFinalize(curTabDrag); curTabDrag = null; } if((curTabCloning != null) && (curTabCloning != Cursors.Default)) { PInvoke.DestroyIcon(curTabCloning.Handle); GC.SuppressFinalize(curTabCloning); curTabCloning = null; } if(dropTargetWrapper != null) { dropTargetWrapper.Dispose(); dropTargetWrapper = null; } OptionsDialog.ForceClose(); if(tabSwitcher != null) { tabSwitcher.Dispose(); tabSwitcher = null; } } if(TravelLog != null) { Marshal.FinalReleaseComObject(TravelLog); TravelLog = null; } if(shellContextMenu != null) { shellContextMenu.Dispose(); shellContextMenu = null; } if(ShellBrowser != null) { ShellBrowser.Dispose(); ShellBrowser = null; } foreach(ITravelLogEntry entry in LogEntryDic.Values) { if(entry != null) { Marshal.FinalReleaseComObject(entry); } } LogEntryDic.Clear(); fFinalRelease = true; base.CloseDW(dwReserved); } catch(Exception exception2) { QTUtility2.MakeErrorLog(exception2, "tabbar closing"); } }