public void ShowWindow(Point pnt, FOLDERVIEWMODE fvmCurrentMode) { const uint SWP_NOACTIVATE = 0x0010; const int SW_SHOWNOACTIVATE = 4; this.trackBar1.Value = FolderViewModeWindow.ModeToInt(fvmCurrentMode); // set the slider of trackbar under mouse position RECT rct = this.GetThumbRect(); Point pntCenter = new Point(rct.left + rct.Width / 2, rct.top + rct.Height / 2); Rectangle rctScreen = Screen.FromPoint(pnt).Bounds; pnt.X = pnt.X - pntCenter.X; pnt.Y = pnt.Y - pntCenter.Y; // ensure visible in the screen if (pnt.X < rctScreen.Left) { pnt.X = rctScreen.Left; } else if (pnt.X + this.Width > rctScreen.Right) { pnt.X = rctScreen.Right - this.Width; } if (pnt.Y < rctScreen.Top) { pnt.Y = rctScreen.Top; } else if (pnt.Y + this.Height > rctScreen.Bottom) { pnt.Y = rctScreen.Bottom - this.Height; } PInvoke.SetWindowPos(this.Handle, (IntPtr)(-1), pnt.X, pnt.Y, this.Width, this.Height, SWP_NOACTIVATE); PInvoke.ShowWindow(this.Handle, SW_SHOWNOACTIVATE); this.trackBar1.Focus(); }
private void labelButtons_Click(object sender, EventArgs e) { FOLDERVIEWMODE mode = (FOLDERVIEWMODE)((LabelEx)sender).Tag; this.trackBar1.Value = FolderViewModeWindow.ModeToInt(mode); }