G
Guest
I have a custom control based on RichTextBox. I want to be able to scroll the text box automatically from inside the code. It seems that the scroll bar scroll like i tell it to, but the window seems to only update a certain part of the text and leaves part of it like it was before. can anyone tell me if i am passing a wrong variable somewhere or what i am doing wrong (or not doing) I try to call Invalidate() and Refresh() but it just paints the text box like it was before scrolling
thanks for your help
--code--
--declaration
[StructLayout(LayoutKind.Sequential)
private struct SCROLLBARINFO
public int cbSize
public UInt32 fMask
public Int32 nMin
public Int32 nMax
public UInt32 nPage
public Int32 nPos
public Int32 nTrackPos
[DllImport("user32")
private static extern bool GetScrollInfo(
IntPtr hwnd
int fnBar
ref SCROLLBARINFO lpsi)
[DllImport("user32")
private static extern int SetScrollInfo(
IntPtr hwnd
int fnBar
ref SCROLLBARINFO lpsi
bool fRedraw)
[DllImport("user32")
private static extern int ScrollWindowEx
IntPtr hWnd
int dx
int dy
Rectangle prcScroll
Rectangle prcClip
IntPtr hrgnUpdate
ref Rectangle prcUpdate
UInt32 flags)
[DllImport("user32")
private static extern bool UpdateWindow
IntPtr hWnd)
--metho
SCROLLBARINFO sInfo = new SCROLLBARINFO()
sInfo.fMask = (0x1 | 0x2 | 0x4)
sInfo.cbSize = Marshal.SizeOf(sInfo);
GetScrollInfo(this.Handle, 0x1, ref sInfo)
pos = sInfo.nMax - sInfo.nPag
sInfo.nPos = Convert.ToInt32(pos)
sInfo.fMask = SIF_POS
sInfo.cbSize = Marshal.SizeOf(sInfo)
SetScrollInfo(this.Handle, 0x1, ref sInfo, true)
Rectangle rect = new Rectangle()
Rectangle rect2 = new Rectangle()
rect = this.ClientRectangle
ScrollWindowEx(this.Handle, 0, sInfo.nPos, Rectangle.Empty, rect, this.Handle, ref rect2, 0x2)
this.Invalidate(this.ClientRectangle)
//RedrawWindow(this.Handle, rect, IntPtr.Zero, 0x1 | 0x4); ??
//UpdateWindow(this.Handle); ??
thanks for your help
--code--
--declaration
[StructLayout(LayoutKind.Sequential)
private struct SCROLLBARINFO
public int cbSize
public UInt32 fMask
public Int32 nMin
public Int32 nMax
public UInt32 nPage
public Int32 nPos
public Int32 nTrackPos
[DllImport("user32")
private static extern bool GetScrollInfo(
IntPtr hwnd
int fnBar
ref SCROLLBARINFO lpsi)
[DllImport("user32")
private static extern int SetScrollInfo(
IntPtr hwnd
int fnBar
ref SCROLLBARINFO lpsi
bool fRedraw)
[DllImport("user32")
private static extern int ScrollWindowEx
IntPtr hWnd
int dx
int dy
Rectangle prcScroll
Rectangle prcClip
IntPtr hrgnUpdate
ref Rectangle prcUpdate
UInt32 flags)
[DllImport("user32")
private static extern bool UpdateWindow
IntPtr hWnd)
--metho
SCROLLBARINFO sInfo = new SCROLLBARINFO()
sInfo.fMask = (0x1 | 0x2 | 0x4)
sInfo.cbSize = Marshal.SizeOf(sInfo);
GetScrollInfo(this.Handle, 0x1, ref sInfo)
pos = sInfo.nMax - sInfo.nPag
sInfo.nPos = Convert.ToInt32(pos)
sInfo.fMask = SIF_POS
sInfo.cbSize = Marshal.SizeOf(sInfo)
SetScrollInfo(this.Handle, 0x1, ref sInfo, true)
Rectangle rect = new Rectangle()
Rectangle rect2 = new Rectangle()
rect = this.ClientRectangle
ScrollWindowEx(this.Handle, 0, sInfo.nPos, Rectangle.Empty, rect, this.Handle, ref rect2, 0x2)
this.Invalidate(this.ClientRectangle)
//RedrawWindow(this.Handle, rect, IntPtr.Zero, 0x1 | 0x4); ??
//UpdateWindow(this.Handle); ??