Esempio n. 1
0
        internal ExtendedListViewCommon(ShellBrowserEx shellBrowser, IntPtr hwndShellView, IntPtr hwndListView, IntPtr hwndSubDirTipMessageReflect)
        {
            ShellBrowser = shellBrowser;
            this.hwndSubDirTipMessageReflect = hwndSubDirTipMessageReflect;

            ListViewController = new NativeWindowController(hwndListView);
            ListViewController.MessageCaptured += ListViewController_MessageCaptured;
            ShellViewController = new NativeWindowController(hwndShellView);
            ShellViewController.MessageCaptured += ShellViewController_MessageCaptured;

            TRACKMOUSEEVENT structure = new TRACKMOUSEEVENT();

            structure.cbSize    = Marshal.SizeOf(structure);
            structure.dwFlags   = 2;
            structure.hwndTrack = ListViewController.Handle;
            PInvoke.TrackMouseEvent(ref structure);

            timer_HoverSubDirTipMenu          = new Timer();
            timer_HoverSubDirTipMenu.Interval = SystemInformation.MouseHoverTime * 6 / 5;
            timer_HoverSubDirTipMenu.Tick    += timer_HoverSubDirTipMenu_Tick;

            hwndExplorer = PInvoke.GetAncestor(hwndShellView, 3 /* GA_ROOTOWNER */);

            // If we're late to the party, we'll have to get the IDropTarget the
            // old-fashioned way.  Careful!  Calling RegisterDragDrop will go
            // through the hook!
            IntPtr ptr = PInvoke.GetProp(hwndListView, "OleDropTargetInterface");

            dropTargetPassthrough = TryMakeDTPassthrough(ptr);
            if (dropTargetPassthrough != null)
            {
                PInvoke.RevokeDragDrop(hwndListView);
                PInvoke.RegisterDragDrop(hwndListView, dropTargetPassthrough);
            }
        }
        private void HookDropTarget()
        {
            if (dropTargetPassthrough != null)
            {
                dropTargetPassthrough.Dispose();
                dropTargetPassthrough = null;
            }
            IntPtr ptr = PInvoke.GetProp(Handle, "OleDropTargetInterface");

            if (ptr != IntPtr.Zero)
            {
                object       obj         = Marshal.GetObjectForIUnknown(ptr);
                _IDropTarget passthrough = obj as _IDropTarget;
                if (passthrough != null)
                {
                    PInvoke.RevokeDragDrop(Handle);
                    dropTargetPassthrough = new DropTargetPassthrough(passthrough, this);
                    PInvoke.RegisterDragDrop(Handle, dropTargetPassthrough);
                }
                else
                {
                    Marshal.ReleaseComObject(obj);
                }
            }
        }
Esempio n. 3
0
 public override void Dispose(bool fDisposing)
 {
     if (fDisposed)
     {
         return;
     }
     // Never call NativeWindow.ReleaseHandle().  EVER!!!
     if (ListViewController != null)
     {
         ListViewController.MessageCaptured -= ListViewController_MessageCaptured;
         ListViewController = null;
     }
     if (ShellViewController != null)
     {
         ShellViewController.MessageCaptured -= ShellViewController_MessageCaptured;
         ShellViewController = null;
     }
     if (timer_HoverSubDirTipMenu != null)
     {
         timer_HoverSubDirTipMenu.Dispose();
         timer_HoverSubDirTipMenu = null;
     }
     if (timer_Thumbnail != null)
     {
         timer_Thumbnail.Dispose();
         timer_Thumbnail = null;
     }
     if (thumbnailTooltip != null)
     {
         thumbnailTooltip.Dispose();
         thumbnailTooltip = null;
     }
     if (subDirTip != null)
     {
         subDirTip.Dispose();
         subDirTip = null;
     }
     if (dropTargetPassthrough != null)
     {
         dropTargetPassthrough.Dispose();
         dropTargetPassthrough = null;
     }
     base.Dispose(fDisposing);
 }
 public override void Dispose(bool fDisposing)
 {
     if (fDisposed)
     {
         return;
     }
     if (ListViewController != null)
     {
         ListViewController.ReleaseHandle();
         ListViewController = null;
     }
     if (ShellViewController != null)
     {
         ShellViewController.ReleaseHandle();
         ShellViewController = null;
     }
     if (timer_HoverSubDirTipMenu != null)
     {
         timer_HoverSubDirTipMenu.Dispose();
         timer_HoverSubDirTipMenu = null;
     }
     if (timer_Thumbnail != null)
     {
         timer_Thumbnail.Dispose();
         timer_Thumbnail = null;
     }
     if (thumbnailTooltip != null)
     {
         thumbnailTooltip.Dispose();
         thumbnailTooltip = null;
     }
     if (subDirTip != null)
     {
         subDirTip.Dispose();
         subDirTip = null;
     }
     if (dropTargetPassthrough != null)
     {
         dropTargetPassthrough.Dispose();
         dropTargetPassthrough = null;
     }
     base.Dispose(fDisposing);
 }
Esempio n. 5
0
        protected virtual bool ListViewController_MessageCaptured(ref Message msg)
        {
            if (msg.Msg == WM_AFTERPAINT)
            {
                RefreshSubDirTip(true);
                return(true);
            }
            else if (msg.Msg == WM_REGISTERDRAGDROP)
            {
                IntPtr ptr = Marshal.ReadIntPtr(msg.WParam);
                if (dropTargetPassthrough != null)
                {
                    // If this is the RegisterDragDrop call from the constructor,
                    // don't mess it up!
                    if (dropTargetPassthrough.Pointer == ptr)
                    {
                        return(true);
                    }
                    dropTargetPassthrough.Dispose();
                }
                dropTargetPassthrough = TryMakeDTPassthrough(ptr);
                if (dropTargetPassthrough != null)
                {
                    Marshal.WriteIntPtr(msg.WParam, dropTargetPassthrough.Pointer);
                }
                return(true);
            }

            switch (msg.Msg)
            {
            case WM.DESTROY:
                HideThumbnailTooltip(7);
                HideSubDirTip(7);
                ListViewController.DefWndProc(ref msg);
                OnListViewDestroyed();
                return(true);

            case WM.PAINT:
                // It's very dangerous to do automation-related things
                // during WM_PAINT.  So, use PostMessage to do it later.
                PInvoke.PostMessage(ListViewController.Handle, WM_AFTERPAINT, IntPtr.Zero, IntPtr.Zero);
                break;

            case WM.MOUSEMOVE:
                ResetTrackMouseEvent();
                break;

            case WM.LBUTTONDBLCLK:
                if (DoubleClick != null)
                {
                    return(DoubleClick(QTUtility2.PointFromLPARAM(msg.LParam)));
                }
                break;

            case WM.MBUTTONUP:
                if (MiddleClick != null)
                {
                    MiddleClick(QTUtility2.PointFromLPARAM(msg.LParam));
                }
                break;

            case WM.MOUSEWHEEL: {
                IntPtr handle = PInvoke.WindowFromPoint(QTUtility2.PointFromLPARAM(msg.LParam));
                if (handle != IntPtr.Zero && handle != msg.HWnd)
                {
                    Control control = Control.FromHandle(handle);
                    if (control != null)
                    {
                        DropDownMenuReorderable reorderable = control as DropDownMenuReorderable;
                        if ((reorderable != null) && reorderable.CanScroll)
                        {
                            PInvoke.SendMessage(handle, WM.MOUSEWHEEL, msg.WParam, msg.LParam);
                        }
                    }
                }
                break;
            }

            case WM.MOUSELEAVE:
                fTrackMouseEvent = true;
                HideThumbnailTooltip(4);
                if (((subDirTip != null) && !subDirTip.MouseIsOnThis()) && !subDirTip.MenuIsShowing)
                {
                    HideSubDirTip(5);
                }
                break;
            }
            return(false);
        }
        internal ExtendedListViewCommon(ShellBrowserEx shellBrowser, IntPtr hwndShellView, IntPtr hwndListView, IntPtr hwndSubDirTipMessageReflect) {
            ShellBrowser = shellBrowser;
            this.hwndSubDirTipMessageReflect = hwndSubDirTipMessageReflect;

            ListViewController = new NativeWindowController(hwndListView);
            ListViewController.MessageCaptured += ListViewController_MessageCaptured;
            ShellViewController = new NativeWindowController(hwndShellView);
            ShellViewController.MessageCaptured += ShellViewController_MessageCaptured;

            TRACKMOUSEEVENT structure = new TRACKMOUSEEVENT();
            structure.cbSize = Marshal.SizeOf(structure);
            structure.dwFlags = 2;
            structure.hwndTrack = ListViewController.Handle;
            PInvoke.TrackMouseEvent(ref structure);

            timer_HoverSubDirTipMenu = new Timer();
            timer_HoverSubDirTipMenu.Interval = SystemInformation.MouseHoverTime * 6 / 5;
            timer_HoverSubDirTipMenu.Tick += timer_HoverSubDirTipMenu_Tick;

            hwndExplorer = PInvoke.GetAncestor(hwndShellView, 3 /* GA_ROOTOWNER */);

            // If we're late to the party, we'll have to get the IDropTarget the
            // old-fashioned way.  Careful!  Calling RegisterDragDrop will go 
            // through the hook!
            IntPtr ptr = PInvoke.GetProp(hwndListView, "OleDropTargetInterface");
            dropTargetPassthrough = TryMakeDTPassthrough(ptr);
            if(dropTargetPassthrough != null) {
                PInvoke.RevokeDragDrop(hwndListView);
                PInvoke.RegisterDragDrop(hwndListView, dropTargetPassthrough);
            }
        }
        protected virtual bool ListViewController_MessageCaptured(ref Message msg) {

            if(msg.Msg == WM_AFTERPAINT) {
                RefreshSubDirTip(true);
                return true;
            }
            else if(msg.Msg == WM_REGISTERDRAGDROP) {
                IntPtr ptr = Marshal.ReadIntPtr(msg.WParam);
                if(dropTargetPassthrough != null) {
                    // If this is the RegisterDragDrop call from the constructor,
                    // don't mess it up!
                    if(dropTargetPassthrough.Pointer == ptr) {
                        return true;
                    }
                    dropTargetPassthrough.Dispose();
                }
                dropTargetPassthrough = TryMakeDTPassthrough(ptr);
                if(dropTargetPassthrough != null) {
                    Marshal.WriteIntPtr(msg.WParam, dropTargetPassthrough.Pointer);
                }
                return true;
            }

            switch(msg.Msg) {
                case WM.DESTROY:
                    HideThumbnailTooltip(7);
                    HideSubDirTip(7);
                    ListViewController.DefWndProc(ref msg);
                    OnListViewDestroyed();
                    return true;

                case WM.PAINT:
                    // It's very dangerous to do automation-related things
                    // during WM_PAINT.  So, use PostMessage to do it later.
                    PInvoke.PostMessage(ListViewController.Handle, WM_AFTERPAINT, IntPtr.Zero, IntPtr.Zero);
                    break;

                case WM.MOUSEMOVE:
                    ResetTrackMouseEvent();
                    break;

                case WM.LBUTTONDBLCLK:
                    if(DoubleClick != null) {
                        return DoubleClick(QTUtility2.PointFromLPARAM(msg.LParam));
                    }
                    break;
                
                case WM.MBUTTONUP:
                    if(MiddleClick != null) {
                        MiddleClick(QTUtility2.PointFromLPARAM(msg.LParam));
                    }
                    break;

                case WM.MOUSEWHEEL: {
                    IntPtr handle = PInvoke.WindowFromPoint(QTUtility2.PointFromLPARAM(msg.LParam));
                    if(handle != IntPtr.Zero && handle != msg.HWnd) {
                        Control control = Control.FromHandle(handle);
                        if(control != null) {
                            DropDownMenuReorderable reorderable = control as DropDownMenuReorderable;
                            if((reorderable != null) && reorderable.CanScroll) {
                                PInvoke.SendMessage(handle, WM.MOUSEWHEEL, msg.WParam, msg.LParam);
                            }
                        }
                    }
                    break;
                }

                case WM.MOUSELEAVE:
                    fTrackMouseEvent = true;
                    HideThumbnailTooltip(4);
                    if(((subDirTip != null) && !subDirTip.MouseIsOnThis()) && !subDirTip.MenuIsShowing) {
                        HideSubDirTip(5);
                    }
                    break;
            }
            return false;
        }
 public override void Dispose(bool fDisposing) {
     if(fDisposed) return;
     if(ListViewController != null) {
         ListViewController.ReleaseHandle();
         ListViewController = null;
     }
     if(ShellViewController != null) {
         ShellViewController.ReleaseHandle();
         ShellViewController = null;
     }
     if(timer_HoverSubDirTipMenu != null) {
         timer_HoverSubDirTipMenu.Dispose();
         timer_HoverSubDirTipMenu = null;
     }
     if(timer_Thumbnail != null) {
         timer_Thumbnail.Dispose();
         timer_Thumbnail = null;
     }
     if(thumbnailTooltip != null) {
         thumbnailTooltip.Dispose();
         thumbnailTooltip = null;
     }
     if(subDirTip != null) {
         subDirTip.Dispose();
         subDirTip = null;
     }
     if(dropTargetPassthrough != null) {
         dropTargetPassthrough.Dispose();
         dropTargetPassthrough = null;
     }
     base.Dispose(fDisposing);
 }
 public override void Dispose(bool fDisposing) {
     if(fDisposed) return;
     // Never call NativeWindow.ReleaseHandle().  EVER!!!
     if(ListViewController != null) {
         ListViewController.MessageCaptured -= ListViewController_MessageCaptured;
         ListViewController = null;
     }
     if(ShellViewController != null) {
         ShellViewController.MessageCaptured -= ShellViewController_MessageCaptured;
         ShellViewController = null;
     }
     if(timer_HoverSubDirTipMenu != null) {
         timer_HoverSubDirTipMenu.Dispose();
         timer_HoverSubDirTipMenu = null;
     }
     if(timer_Thumbnail != null) {
         timer_Thumbnail.Dispose();
         timer_Thumbnail = null;
     }
     if(thumbnailTooltip != null) {
         thumbnailTooltip.Dispose();
         thumbnailTooltip = null;
     }
     if(subDirTip != null) {
         subDirTip.Dispose();
         subDirTip = null;
     }
     if(dropTargetPassthrough != null) {
         dropTargetPassthrough.Dispose();
         dropTargetPassthrough = null;
     }
     base.Dispose(fDisposing);
 }
 private void HookDropTarget() {
     if(dropTargetPassthrough != null) {
         dropTargetPassthrough.Dispose();
         dropTargetPassthrough = null;
     }
     IntPtr ptr = PInvoke.GetProp(Handle, "OleDropTargetInterface");
     if(ptr != IntPtr.Zero) {
         object obj = Marshal.GetObjectForIUnknown(ptr);
         _IDropTarget passthrough = obj as _IDropTarget;
         if(passthrough != null) {
             PInvoke.RevokeDragDrop(Handle);
             dropTargetPassthrough = new DropTargetPassthrough(passthrough, this);
             PInvoke.RegisterDragDrop(Handle, dropTargetPassthrough);
         }
         else {
             Marshal.ReleaseComObject(obj);
         }
     }
 }