A
Alex Fu
I create a utility class, and call
GetScrollInfo(txtHelp, (int)ScrollBarDirection.SB_VERT);
txtHelp is a RichTextBox component instance.
Please tell me why GetScrollInfo doesn't work. Thanks.
-------------------------------------
using System;
using System.Runtime.InteropServices;
namespace Alex.Plan
{
[StructLayout(LayoutKind.Sequential)]
public struct SCROLLINFO
{
public int cbSize;
public uint fMask;
public int nMin;
public int nMax;
public uint nPage;
public int nPos;
public int nTrackPos;
}
public enum ScrollBarDirection
{
SB_HORZ = 0,
SB_VERT = 1,
SB_CTL = 2,
SB_BOTH = 3
}
public enum ScrollInfoMask
{
SIF_RANGE = 0x1,
SIF_PAGE = 0x2,
SIF_POS = 0x4,
SIF_DISABLENOSCROLL = 0x8,
SIF_TRACKPOS = 0x16,
SIF_ALL = SIF_RANGE + SIF_PAGE + SIF_POS + SIF_TRACKPOS
}
/// <summary>
/// Summary description for NativeUtil.
/// </summary>
public class NativeUtil
{
[DllImport("user32.dll")]
private static extern bool GetScrollInfo(IntPtr hwnd, int fnBar,
ref SCROLLINFO ScrollInfo);
public static SCROLLINFO
GetScrollInfo(System.Windows.Forms.RichTextBox richtxt, int fnBar)
{
SCROLLINFO info = new SCROLLINFO();
info.cbSize = Marshal.SizeOf(info);
info.fMask = (int) ScrollInfoMask.SIF_ALL;
GetScrollInfo(richtxt.Handle, fnBar, ref info);
return info;
}
}
}
Regards
Alex
GetScrollInfo(txtHelp, (int)ScrollBarDirection.SB_VERT);
txtHelp is a RichTextBox component instance.
Please tell me why GetScrollInfo doesn't work. Thanks.
-------------------------------------
using System;
using System.Runtime.InteropServices;
namespace Alex.Plan
{
[StructLayout(LayoutKind.Sequential)]
public struct SCROLLINFO
{
public int cbSize;
public uint fMask;
public int nMin;
public int nMax;
public uint nPage;
public int nPos;
public int nTrackPos;
}
public enum ScrollBarDirection
{
SB_HORZ = 0,
SB_VERT = 1,
SB_CTL = 2,
SB_BOTH = 3
}
public enum ScrollInfoMask
{
SIF_RANGE = 0x1,
SIF_PAGE = 0x2,
SIF_POS = 0x4,
SIF_DISABLENOSCROLL = 0x8,
SIF_TRACKPOS = 0x16,
SIF_ALL = SIF_RANGE + SIF_PAGE + SIF_POS + SIF_TRACKPOS
}
/// <summary>
/// Summary description for NativeUtil.
/// </summary>
public class NativeUtil
{
[DllImport("user32.dll")]
private static extern bool GetScrollInfo(IntPtr hwnd, int fnBar,
ref SCROLLINFO ScrollInfo);
public static SCROLLINFO
GetScrollInfo(System.Windows.Forms.RichTextBox richtxt, int fnBar)
{
SCROLLINFO info = new SCROLLINFO();
info.cbSize = Marshal.SizeOf(info);
info.fMask = (int) ScrollInfoMask.SIF_ALL;
GetScrollInfo(richtxt.Handle, fnBar, ref info);
return info;
}
}
}
Regards
Alex