public static void ScrollTextChanged(RichTextBox richTextBox, ChatBoxScrollbar.ChatBoxScrollbar advancedVScrollbar)
        {
            SCROLLINFO scrollinfo = GetScrollInfo(richTextBox);

            if (scrollinfo.nMax > advancedVScrollbar.Maximum + richTextBox.Height)
            {
                PreviousRichTextBoxHeight        = richTextBox.Height;
                advancedVScrollbar.Maximum       = scrollinfo.nMax - richTextBox.Height;
                advancedVScrollbar.ThumbPosition = advancedVScrollbar.Maximum;
                SetScrollingInfo(richTextBox.Handle, advancedVScrollbar.Maximum);
            }
        }
        public static void ScrollVertically(RichTextBox richTextBox, ChatBoxScrollbar.ChatBoxScrollbar advancedVScrollbar)
        {
            SCROLLINFO scrollinfo = GetScrollInfo(richTextBox);

            if (advancedVScrollbar.ThumbPosition != scrollinfo.nTrackPos)
            {
                if (scrollinfo.nMax > advancedVScrollbar.Maximum + richTextBox.Height)
                {
                    PreviousRichTextBoxHeight  = richTextBox.Height;
                    advancedVScrollbar.Maximum = scrollinfo.nMax - richTextBox.Height;
                }

                advancedVScrollbar.ThumbPosition = scrollinfo.nTrackPos;
            }
        }
        public static void ScrollSizeChanged(RichTextBox richTextBox, ChatBoxScrollbar.ChatBoxScrollbar advancedVScrollbar)
        {
            ///a litle bug here, have a look a it later, in certain situations trackbar freezes
            if (advancedVScrollbar.Maximum >= 0)
            {
                SCROLLINFO scrollinfo = GetScrollInfo(richTextBox);
                if (scrollinfo.nMax - richTextBox.Height > 0)
                {
                    richTextBox.ScrollToCaret();
                    advancedVScrollbar.Maximum = scrollinfo.nMax - richTextBox.Height;

                    if (scrollinfo.nTrackPos <= advancedVScrollbar.Maximum)
                    {
                        advancedVScrollbar.ThumbPosition = scrollinfo.nTrackPos;
                    }
                    else
                    {
                        advancedVScrollbar.ThumbPosition = advancedVScrollbar.Maximum;
                    }
                }
            }
        }
 public static void AdjustRichTextBoxSize(RichTextBox richTextBox, ChatBoxScrollbar.ChatBoxScrollbar advancedVScrollbar)
 {
     richTextBox.Width -= advancedVScrollbar.Width - SystemInformation.VerticalScrollBarWidth;
 }
 public static void AdjustVScrollbarLocation(RichTextBox richTextBox, ChatBoxScrollbar.ChatBoxScrollbar advancedVScrollbar)
 {
     advancedVScrollbar.Location = new Point(richTextBox.Location.X + richTextBox.Width - SystemInformation.VerticalScrollBarWidth, richTextBox.Location.Y);
     advancedVScrollbar.Height   = richTextBox.Height;
     advancedVScrollbar.Width    = SystemInformation.VerticalScrollBarWidth;
 }