得到鼠标点知位置,然后设置滚动条位置 foreach (Control controls in groupbox.Controls) { if (controls is VScrollBar) continue; controls.Tag = controls.Location.Y; }
用api函数去控制滚动条 这是我实现代码 public struct SCROLLINFO { public uint cbSize; public uint fMask; public int nMin; public int nMax; public uint nPage; public int nPos; public int nTrackPos; } [DllImport("user32.dll", EntryPoint = "GetScrollInfo")] public static extern bool GetScrollInfo(IntPtr hwnd, int fnBar, ref SCROLLINFO lpsi); SCROLLINFO si = new SCROLLINFO();bool result = GetScrollInfo(intPtr, 1, ref si);为什么result 总是false???
直接发送消息就可以实现了 const int WM_VSCROLL = (int)0x0115; SendMessage(this.Handle, WM_VSCROLL, (int)ScrollBarRequests.SB_TOP, 0);
foreach (Control controls in groupbox.Controls)
{
if (controls is VScrollBar) continue;
controls.Tag = controls.Location.Y;
}
这是我实现代码
public struct SCROLLINFO
{
public uint cbSize; public uint fMask; public int nMin; public int nMax; public uint nPage; public int nPos; public int nTrackPos;
}
[DllImport("user32.dll", EntryPoint = "GetScrollInfo")] public static extern bool GetScrollInfo(IntPtr hwnd, int fnBar, ref SCROLLINFO lpsi);
SCROLLINFO si = new SCROLLINFO();bool result = GetScrollInfo(intPtr, 1, ref si);为什么result 总是false???
const int WM_VSCROLL = (int)0x0115;
SendMessage(this.Handle, WM_VSCROLL, (int)ScrollBarRequests.SB_TOP, 0);