bool IMessageFilter.PreFilterMessage(ref Message m) { HResult hr = HResult.False; Message M = m; if (explorerBrowserControl != null) { // translate keyboard input if (m.Msg == (int)WindowsAPI.WndMsg.WM_ACTIVATEAPP) { MessageBox.Show("Active"); } if (m.Msg == (int)WindowsAPI.WndMsg.WM_SETFOCUS) { MessageBox.Show("Active"); } // Catch Left Mouse Click key if ((m.Msg == (int)WindowsAPI.WndMsg.WM_LBUTTONDOWN)) { if (KeyUP != null) { ExplorerKeyUPEventArgs args = new ExplorerKeyUPEventArgs(); args.Key = 778; KeyUP(this, args); } //WindowsAPI.SetFocus(SysListViewHandle); WindowsAPI.RECTW r = new WindowsAPI.RECTW(); WindowsAPI.GetWindowRect(SysListViewHandle, ref r); Rectangle reclv = r.ToRectangle(); if (Cursor.Position.Y >= reclv.Top && Cursor.Position.Y <= reclv.Top + 29) { IsMouseClickOnHeader = true; } else { IsMouseClickOnHeader = false; } if (reclv.Contains(Cursor.Position)) { IsPressedLKButton = true; } else { IsPressedLKButton = false; } //MessageBox.Show(Cursor.Position.Y.ToString() + @"\" + reclv.Top.ToString()); if (Cursor.Position.Y <= reclv.Top || Cursor.Position.Y >= reclv.Bottom) { IsMouseClickOutsideLV = true; } else { IsMouseClickOutsideLV = false; } } if ((m.Msg == (int)WindowsAPI.WndMsg.WM_LBUTTONUP)) { IsPressedLKButton = false; IsMouseClickOnHeader = false; //WindowsAPI.ReleaseCapture(); //WindowsAPI.SetFocus(SysListViewHandle); if (KeyUP != null) { ExplorerKeyUPEventArgs args = new ExplorerKeyUPEventArgs(); args.Key = 777; KeyUP(this, args); } } if (m.Msg == (int)WindowsAPI.WndMsg.WM_XBUTTONUP) { switch (HiWord((int)m.WParam)) { case 1: NavigateLogLocation(NavigationLogDirection.Backward); break; case 2: NavigateLogLocation(NavigationLogDirection.Forward); break; } } bool h = false; if ((m.Msg == (int)WindowsAPI.WndMsg.WM_SYSCOMMAND)) { } if (m.Msg == (int)WindowsAPI.WndMsg.WM_MOUSEWHEEL) { int Wheel_delta = HiWord((int)m.WParam); if (LoWord((int)m.WParam) == 0x0008) //Ctrl is down { if (Wheel_delta < 0) { if (ContentOptions.ThumbnailSize > 34) { if (ContentOptions.ViewMode != ExplorerBrowserViewMode.Thumbnail) { ContentOptions.ViewMode = ExplorerBrowserViewMode.Thumbnail; } ContentOptions.ThumbnailSize = ContentOptions.ThumbnailSize - 10; } } else { if (ContentOptions.ThumbnailSize < 255) { if (ContentOptions.ViewMode != ExplorerBrowserViewMode.Thumbnail) { ContentOptions.ViewMode = ExplorerBrowserViewMode.Thumbnail; } ContentOptions.ThumbnailSize = ContentOptions.ThumbnailSize + 10; } } } } if ((m.Msg == (int)WindowsAPI.WndMsg.WM_MOUSE_ENTER)) { //WindowsAPI.SetFocus(SysListViewHandle); } if ((m.Msg == (int)WindowsAPI.WndMsg.WM_MOUSE_LEAVE)) { ExplorerBrowserMouseLeave.Invoke(this, null); } if (m.Msg == (int)WindowsAPI.WndMsg.WM_KEYDOWN) { // Catch ESC key if (((int)m.WParam == 27)) OnEscKey(); if (KeyUP != null) { ExplorerKeyUPEventArgs args = new ExplorerKeyUPEventArgs(); args.Key = (int)m.WParam; KeyUP(this, args); } if ((int)m.WParam == (int)Keys.ControlKey) { Ctrl = true; } if (!IsExFileOpEnabled) { if ((int)m.WParam == (int)Keys.X && Ctrl) { IsMoveClipboardOperation = true; } if ((int)m.WParam == (int)Keys.C && Ctrl) { IsMoveClipboardOperation = false; } if ((int)m.WParam == (int)Keys.V && Ctrl) { if (!Clipboard.ContainsText()) { if (Clipboard.ContainsFileDropList()) { ShellObject sho; try { sho = ShellObject.FromParsingName(System.Windows.Forms.Clipboard.GetFileDropList()[0]); } catch (Exception) { sho = null; } if (sho != null) { sho.Dispose(); DropData PasteData = new DropData(); PasteData.DropList = System.Windows.Forms.Clipboard.GetFileDropList(); if (SelectedItems.Count > 0 & SelectedItems.Count < 2) { PasteData.PathForDrop = SelectedItems[0].ParsingName; } else { PasteData.PathForDrop = NavigationLog.CurrentLocation.ParsingName; } Thread t = null; if (IsMoveClipboardOperation) { t = new Thread(new ParameterizedThreadStart(DoMove)); } else { t = new Thread(new ParameterizedThreadStart(DoCopy)); } t.SetApartmentState(ApartmentState.STA); t.Start(PasteData); return true; } } } } } } if (m.Msg == (int)WindowsAPI.WndMsg.WM_KEYUP) { if (KeyUP != null) { ExplorerKeyUPEventArgs args = new ExplorerKeyUPEventArgs(); args.Key = (int)m.WParam; KeyUP(this, args); } if ((int)m.WParam == (int)Keys.ControlKey) { Ctrl = false; } if (!IsExFileOpEnabled) { if ((int)m.WParam == (int)Keys.V && Ctrl) { return true; } } } if ((m.Msg == (int)WindowsAPI.WndMsg.WM_MOUSEMOVE)) { WindowsAPI.RECTW rscroll = new WindowsAPI.RECTW(); WindowsAPI.GetWindowRect(VScrollHandle, ref rscroll); WindowsAPI.RECTW rr = new WindowsAPI.RECTW(); WindowsAPI.GetWindowRect(SysListViewHandle, ref rr); Rectangle reclv = rr.ToRectangle(); Rectangle rec2 = new Rectangle(reclv.X + 1, rscroll.Top + 30, reclv.Width - 3, rscroll.Bottom - rscroll.Top - 5 - 30); //ExplorerBrowser.Checktmr.Start(); //A workarownd to ugly AutoScroll bug in IExplorerBrowsers if (m.WParam.ToInt32() == 0x0001 && !IsMouseClickOnHeader && !IsMouseClickOutsideLV) { ShellObject s; if (rscroll.Height > 0) if (!rec2.Contains(Cursor.Position)) { if (Cursor.Position.Y <= rec2.Y) { Cursor.Position = new Point(Cursor.Position.X, rec2.Top); return true; } if (Cursor.Position.Y >= rec2.Bottom) { Cursor.Position = new Point(Cursor.Position.X, rec2.Bottom - 1); return true; } } } else { BeginInvoke(new MethodInvoker( delegate { Guid iid = new Guid(ExplorerBrowserIIDGuid.IShellView); IntPtr view = IntPtr.Zero; HResult hrr = this.explorerBrowserControl.GetCurrentView(ref iid, out view); if (view != IntPtr.Zero) { IShellView isv = (IShellView)Marshal.GetObjectForIUnknown(view); AvailableVisibleColumns = AvailableColumns(isv, false); Marshal.ReleaseComObject(isv); } })); } if (!reclv.Contains(Cursor.Position)) { if (ExplorerBrowserMouseLeave != null) ExplorerBrowserMouseLeave.Invoke(this, null); } BeginInvoke(new MethodInvoker( delegate { WindowsAPI.RECTW r = new WindowsAPI.RECTW(); WindowsAPI.GetWindowRect(SysListViewHandle, ref r); Rectangle recb = r.ToRectangle(); Rectangle PopFR = new Rectangle(PopFX, PopFY, 22, 22); if (recb.Contains(Cursor.Position)) { if (CurX != ((int)M.LParam & 0x0000FFFF) | CurY != HiWord((int)M.LParam)) { try { if (!IsBool && !PopFR.Contains(Cursor.Position)) { // automan.DoQuery(factory => // { // QTTabBarLib.Automation.AutomationElement el; // try // { // el = factory.FromPoint(Cursor.Position); // } // catch // { // // el = null; // } // // if (el != null) // { // string name = el.GetClassName(); // string name2 = el.GetParent().GetClassName(); // if (name == "UIProperty" || name == "UIImage") // { // el = el.GetParent(); // } // // if (el.GetClassName() == "UIItem") // { // //MessageBox.Show(el.GetBoundingRect().Top.ToString() + "/" + el.GetBoundingRect().Left.ToString() + " - " + el.GetClassName()); // Rectangle ImageRecT = new Rectangle(); // Rectangle TextRecT = new Rectangle(); // // foreach (QTTabBarLib.Automation.AutomationElement elm in el.GetChildren()) // { // //MessageBox.Show(elm.GetClassName()); // if (elm.GetClassName() == "UIImage") // { // ImageRecT = elm.GetBoundingRect(); // } // if (elm.GetClassName() == "UIProperty") // { // // TextRecT = new Rectangle(ImageRecT.Left, // ImageRecT.Top, // AvailableVisibleColumns[0].Width, elm.GetBoundingRect().Height); // } // } // // vItemHot(el.GetClassName(), el.GetItemName(), el.GetBoundingRect(), el.GetItemIndex(), false, ImageRecT, TextRecT); // } // else // { // //MessageBox.Show(name); // if (el.GetClassName() == "UIItemsView" | el.GetClassName() == "UIGroupItem") // { // vItemHot(el.GetClassName(), el.GetItemName(), el.GetBoundingRect(), el.GetItemIndex(), true, new Rectangle(0, 0, 0, 0), new Rectangle(0, 0, 0, 0)); // } // else // { // vItemHot(el.GetClassName(), el.GetItemName(), el.GetBoundingRect(), el.GetItemIndex(), true, new Rectangle(0, 0, 0, 0), new Rectangle(0, 0, 0, 0)); // } // // } // el.Dispose(); // } // // return 1; // }); } else { } } catch (Exception ex) { if (automan != null) { automan.Dispose(); } //return 1; } CurX = LoWord((int)M.LParam); CurY = HiWord((int)M.LParam); } } })); } if (m.Msg == (int)WindowsAPI.WndMsg.WM_PAINT) { if (IsOldSysListView) { WindowsAPI.SendMessage(SysListViewHandle, 296, MAKELONG(1, 1), 0); } } Invoke(new MethodInvoker( delegate { hr = ((IInputObject)explorerBrowserControl).TranslateAcceleratorIO(ref M); })); } return (hr == HResult.Ok); }
void Checktmr_Tick(object sender, EventArgs e) { //if (true) // { //IntPtr n = WindowsAPI.FindWindowEx(this.Handle, IntPtr.Zero, "ExplorerBrowserControl", null); //IntPtr z = WindowsAPI.FindWindowEx(n, IntPtr.Zero, "DUIViewWndClassName", null); //IntPtr o = WindowsAPI.FindWindowEx(z, IntPtr.Zero, "DirectUIHWND", null); //IntPtr s1 = WindowsAPI.FindWindowEx(o, IntPtr.Zero, "CtrlNotifySink", null); //IntPtr s2 = WindowsAPI.FindWindowEx(o, s1, "CtrlNotifySink", null); //IntPtr s3 = WindowsAPI.FindWindowEx(o, s2, "CtrlNotifySink", null); //IntPtr k = WindowsAPI.FindWindowEx(s3, IntPtr.Zero, "SHELLDLL_DefView", null); //SysListViewHandle = WindowsAPI.FindWindowEx(k, IntPtr.Zero, "SysListView32", null); //if (SysListViewHandle == IntPtr.Zero) //{ // SysListViewHandle = WindowsAPI.FindWindowEx(k, IntPtr.Zero, "DirectUIHWND", null); //} //IntPtr s4 = WindowsAPI.FindWindowEx(SysListViewHandle, IntPtr.Zero, "CtrlNotifySink", null); //IntPtr s5 = WindowsAPI.FindWindowEx(SysListViewHandle, s4, "CtrlNotifySink", null); //VScrollHandle = WindowsAPI.FindWindowEx(s5, IntPtr.Zero, "ScrollBar", null); WindowsAPI.RECTW r = new WindowsAPI.RECTW(); WindowsAPI.GetWindowRect(SysListViewHandle, ref r); Rectangle recb = r.ToRectangle(); //} if (recb.Contains(Cursor.Position)) { QTTabBarLib.Automation.AutomationManager automan = null; try { automan = new QTTabBarLib.Automation.AutomationManager(); automan.DoQuery(factory => { QTTabBarLib.Automation.AutomationElement el = factory.FromPoint(Cursor.Position); if (el != null) { string name = el.GetClassName(); MessageBox.Show(name); if (el.GetClassName() == "UIItem") { // MessageBox.Show(el.GetBoundingRect().Top.ToString() + "/" + el.GetBoundingRect().Left.ToString() + " - " + el.GetClassName()); // vItemHot(el.GetClassName(), el.GetItemName(), el.GetBoundingRect(), el.GetItemIndex(), false); } else { if (el.GetClassName() == "UIItemsView" || el.GetClassName() == "UIGroupItem") { vItemHot(el.GetClassName(), el.GetItemName(), el.GetBoundingRect(), el.GetItemIndex(), true, new Rectangle(0,0,0,0), new Rectangle(0,0,0,0)); } else { vItemHot(el.GetClassName(), el.GetItemName(), el.GetBoundingRect(), el.GetItemIndex(),true, new Rectangle(0, 0, 0, 0), new Rectangle(0, 0, 0, 0)); } } el.Dispose(); } return 0; }); automan.Dispose(); } catch (Exception ex) { if (automan != null) { automan.Dispose(); } //return 1; } } }