/// <summary> /// Notify the parent form when this is moved. /// </summary> protected override void OnMove(EventArgs e) { if (ParentObject != null && ThisObjectMovedWithLeftMouse) { ParentObject.ChildMoved(this); } if (LeftMouseButtonDown) { ThisObjectMovedWithLeftMouse = true; } base.OnMove(e); }
/// <summary> /// Capture the Window messages for the form to take the appropriate actions. /// Normal events don't fire because of our of the PerPixelAlpaForm inheritance. /// </summary> protected override void WndProc(ref Message m) { if (m.Msg == Constants.WindowMessageConstants.WM_NCRBUTTONDOWN) { // Do nothing } else if (m.Msg == Constants.WindowMessageConstants.WM_NCRBUTTONUP) { contextMenuStrip.Show(); contextMenuStrip.Left = MousePosition.X; contextMenuStrip.Top = MousePosition.Y; return; } else if (m.Msg == Constants.WindowMessageConstants.WM_NCLBUTTONDBLCLK) { //return; } else if (m.Msg == Constants.WindowMessageConstants.WM_NCLBUTTONDOWN) { LeftMouseButtonDown = true; PreviousOpacity = ObjectOpacity; DrawBitmapManaged(ObjectSize.Width, ObjectSize.Height, false, 0, 0, false, 0, 0, 0, 0, true, ObjectOpacity / 2); } //else if (m.Msg == Constants.WindowMessageConstants.WM_NCLBUTTONUP) //{ // // This doesn't work // Console.WriteLine("Moved"); // return; //} else if (m.Msg == Constants.WindowMessageConstants.WM_CAPTURECHANGED) { if (LeftMouseButtonDown && !(MouseButtons == MouseButtons.Left)) { DrawBitmapManaged(ObjectSize.Width, ObjectSize.Height, false, 0, 0, false, 0, 0, 0, 0, true, PreviousOpacity); PreviousOpacity = ObjectOpacity; if (ThisObjectMovedWithLeftMouse) { Console.WriteLine("Dock Item: Object Moved with Mouse"); if (ParentObject != null) { ParentObject.ChildMoved(this); } } else { Console.WriteLine("Dock Item Mouse Left Click"); if (DockItemSectionName != null && DockItemSettings.GetEntry(DockItemSectionName, @"Action") == @"[link]") { FileOperations.Open(DockItemSettings.GetEntry(DockItemSectionName, @"Args")); } else if (DockItemSectionName != null && DockItemSettings.GetEntry(DockItemSectionName, @"Action") == @"[dockfolder]") { ParentObject.ShowLevel(DockItemSectionName + @"-"); } else if (FileOperations._Path != null) { FileOperations.Open(@FileOperations._Path); } } LeftMouseButtonDown = false; ThisObjectMovedWithLeftMouse = false; } } else if (m.Msg == 0x0084 /*WM_NCHITTEST*/) { m.Result = (IntPtr)2; // HTCLIENT return; } base.WndProc(ref m); }