Click here to Skip to main content
15,900,461 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Using Jet Oledb as linked server and trigger rows from VB6.0 Pin
Eddy Vluggen10-Feb-10 0:14
professionalEddy Vluggen10-Feb-10 0:14 
Questionvertical scrollbar for rtb Pin
MA Awan7-Feb-10 23:54
MA Awan7-Feb-10 23:54 
AnswerRe: vertical scrollbar for rtb Pin
DaveAuld8-Feb-10 0:16
professionalDaveAuld8-Feb-10 0:16 
GeneralRe: vertical scrollbar for rtb Pin
MA Awan8-Feb-10 0:25
MA Awan8-Feb-10 0:25 
GeneralRe: vertical scrollbar for rtb Pin
DaveAuld8-Feb-10 1:04
professionalDaveAuld8-Feb-10 1:04 
RantRe: vertical scrollbar for rtb Pin
William Winner8-Feb-10 9:33
William Winner8-Feb-10 9:33 
GeneralRe: vertical scrollbar for rtb Pin
DaveAuld8-Feb-10 20:09
professionalDaveAuld8-Feb-10 20:09 
AnswerRe: vertical scrollbar for rtb [modified] Pin
William Winner8-Feb-10 9:32
William Winner8-Feb-10 9:32 
There is a way to get information about the scrolling. The code below will intercept the vertical and horizontal scroll calls and then get the information relating to them. Add the code below as a new class in your project.

Then, on your form, add a Label where the information will go to and on the load, create a new instance of this class passing in the RichTextBox and the Label. Then, whenever you scroll the information will be updated. The nPos tells you the bottom Y position of the last full line (unless you scroll to the top). If you scroll to the top, the nPos will display 0. If you have any questions about the code let me know.

You can use this to get the info you want. It's just a matter of interpreting the information.


VB
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports System.Drawing

Public Class ScrollInterceptor
    Inherits NativeWindow

    Private Const WM_HSCROLL As Integer = 276
    Private Const WM_VSCROLL As Integer = 277
    Private Const SIF_TRACKPOS As Integer = &H10
    Private Const SIF_RANGE As Integer = &H1
    Private Const SIF_POS As Integer = &H4
    Private Const SIF_PAGE As Integer = &H2
    Private Const SIF_ALL As Integer = SIF_PAGE Or SIF_POS Or SIF_RANGE Or SIF_TRACKPOS
    Private myLabel As Label
    Private myTextBox As RichTextBox


    <DllImport("user32.dll", SetLastError:=True)> _
    Private Shared Function GetScrollInfo(ByVal hWnd As IntPtr, ByVal n As Integer, ByRef lpScrollInfo As ScrollInfoStruct) As Integer
    End Function

    Private Structure ScrollInfoStruct
        Public cbSize As Integer
        Public fMask As Integer
        Public nMin As Integer
        Public nMax As Integer
        Public nPage As Integer
        Public nPos As Integer
        Public nTrackPos As Integer
    End Structure

    Public Sub New(ByRef callingRichTextBox As RichTextBox, ByRef LabelToUpdateTo As Label)
        Me.AssignHandle(callingRichTextBox.Handle)
        myLabel = LabelToUpdateTo
        myTextBox = callingRichTextBox
    End Sub

    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        MyBase.WndProc(m)

        Select Case m.Msg
            Case WM_HSCROLL, WM_VSCROLL
                Dim sInfo As New ScrollInfoStruct
                sInfo.fMask = SIF_ALL
                sInfo.cbSize = Len(sInfo)
                GetScrollInfo(m.HWnd, 1, sInfo)
                myLabel.Text = "nPos = " & sInfo.nPos & vbNewLine &
                               "char = " & myTextBox.GetCharFromPosition(New Point(1, sInfo.nPos)) & vbNewLine & _
                               "line = " & myTextBox.GetLineFromCharIndex(myTextBox.GetCharIndexFromPosition(New Point(1, sInfo.nPos)))

        End Select
    End Sub
modified on Monday, February 8, 2010 4:22 PM

GeneralRe: vertical scrollbar for rtb Pin
MA Awan8-Feb-10 16:53
MA Awan8-Feb-10 16:53 
Questionneed help on User-defined type not defined Pin
joselito j. mebolos7-Feb-10 19:43
joselito j. mebolos7-Feb-10 19:43 
AnswerRe: need help on User-defined type not defined Pin
Eddy Vluggen7-Feb-10 20:56
professionalEddy Vluggen7-Feb-10 20:56 
GeneralRe: need help on User-defined type not defined Pin
joselito j. mebolos8-Feb-10 22:28
joselito j. mebolos8-Feb-10 22:28 
GeneralRe: need help on User-defined type not defined Pin
Eddy Vluggen8-Feb-10 23:49
professionalEddy Vluggen8-Feb-10 23:49 
QuestionView Network SQL Servers Pin
Yosh_6-Feb-10 23:00
professionalYosh_6-Feb-10 23:00 
AnswerRe: View Network SQL Servers Pin
DaveAuld6-Feb-10 23:09
professionalDaveAuld6-Feb-10 23:09 
GeneralRe: View Network SQL Servers Pin
Yosh_7-Feb-10 1:42
professionalYosh_7-Feb-10 1:42 
GeneralRe: View Network SQL Servers Pin
DaveAuld7-Feb-10 2:02
professionalDaveAuld7-Feb-10 2:02 
GeneralRe: View Network SQL Servers Pin
Dave Kreskowiak7-Feb-10 8:37
mveDave Kreskowiak7-Feb-10 8:37 
GeneralRe: View Network SQL Servers Pin
William Winner8-Feb-10 10:27
William Winner8-Feb-10 10:27 
GeneralRe: View Network SQL Servers Pin
Dave Kreskowiak8-Feb-10 15:54
mveDave Kreskowiak8-Feb-10 15:54 
AnswerRe: View Network SQL Servers Pin
tosch7-Feb-10 20:44
tosch7-Feb-10 20:44 
GeneralRe: View Network SQL Servers Pin
Luc Pattyn8-Feb-10 10:44
sitebuilderLuc Pattyn8-Feb-10 10:44 
QuestionAssistance on Syntax with regards to Runtime Error-91 in VB 6.0 Pin
Ace Anthony C. Austria5-Feb-10 23:39
Ace Anthony C. Austria5-Feb-10 23:39 
AnswerRe: Assistance on Syntax with regards to Runtime Error-91 in VB 6.0 Pin
DaveAuld6-Feb-10 3:04
professionalDaveAuld6-Feb-10 3:04 
AnswerRe: Assistance on Syntax with regards to Runtime Error-91 in VB 6.0 Pin
Eddy Vluggen7-Feb-10 21:35
professionalEddy Vluggen7-Feb-10 21:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.