winform 滚动条问题
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);
[DllImport("user32.dll", EntryPoint = "SetScrollInfo")]
public static extern bool SetScrollInfo(IntPtr hwnd, int fnBar, ref SCROLLINFO lpsi, bool Rush);
//获取句柄
IntPtr intPtr = FindWindow(null, "Form1");
SCROLLINFO si = new SCROLLINFO();
si.cbSize = (uint)Marshal.SizeOf(typeof(SCROLLINFO));
si.fMask = (uint)(ScrollBarInfoFlags.SIF_POS);
si.nPos = 1;
//1纵向,0横向
bool result = SetScrollInfo(ss, 1, ref si, true);
当 si.nPos = 0或者没有赋值的时候,返回false;
si.nPos有赋值的时候,返回true,但是滚动条位置没有跟着变化,这是为什么??
谢谢! --------------------编程问答-------------------- 没有给 滚动范围吧?
public int nMin;
public int nMax; --------------------编程问答-------------------- 我是设置位置,不是设定范围,应该是不用nMin;nMax; --------------------编程问答-------------------- 如果我在设定后,再次调用GetScrollInfo,是能改变滚动条的位置,但是如果窗体切换了,回来后滚动条又变回了原来的位置了,这是为什么?? --------------------编程问答-------------------- 因为你只对当前窗体使用了 SetScrollInfo .
补充:.NET技术 , C#