Yes, I am referring to the Tool Tip showing up behind the form instead of in
front of the form.
I tried recreating the code in order to make it stand alone so I can post
it, but the problem doesn't occur with my recreated code. I'll post the full
code as soon as I can.
For now, here's the code for the TreeView that I use:
Option Strict On
Option Explicit On
Imports System.Windows.Forms
Namespace SMCI.Common.UI
Public Class SMCITreeView
Inherits TreeView
Private Const SIF_DISABLENOSCROLL As Long = &H8& '8
Private Const SIF_PAGE As Long = &H2&
Private Const SIF_POS As Long = &H4&
Private Const SIF_RANGE As Long = &H1&
Private Const SIF_TRACKPOS As Long = &H10& '10
Private Const SIF_ALL As Long = SIF_RANGE Or SIF_PAGE Or SIF_POS Or
SIF_TRACKPOS
Private Const SBS_HORZ As Long = 0
Private Const SBS_VERT As Long = 1
Private Const WM_VSCROLL As Int32 = &H115
Private Const SB_THUMBPOSITION As Long = 4 ' &H4 'after mouse up
Private pnScrollPage As Integer ' Same as LargeChange
Private pnScrollPos As Integer
Private pnScrollMin As Integer
Private pnScrollMax As Integer
Public IsVScrollVisible As Boolean
Public IsHScrollVisible As Boolean
'Public IsInitComplete As Boolean
' Events
Public Event ScrollChanged()
Public Event VScrollVisibleChanged(ByVal tlVisible As Boolean)
Public Event HScrollVisibleChanged(ByVal tlVisible As Boolean)
Public Structure SCROLLINFO
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
Declare Function GetScrollInfo Lib "user32" (ByVal hWnd As IntPtr, ByVal
nBar As Integer, _
ByRef lpScrollInfo As SCROLLINFO) As Integer
Declare Auto Function SendMessage Lib "User32" (ByVal hwnd As System.IntPtr,
ByVal msg As Int32, _
ByVal wParams As Int64, ByVal lParams As Int32) As Long
Public ReadOnly Property ScrollPage() As Integer
Get
Return Me.pnScrollPage
End Get
End Property
Public ReadOnly Property ScrollPos() As Integer
Get
Return Me.pnScrollPos
End Get
End Property
Public ReadOnly Property ScrollMin() As Integer
Get
Return Me.pnScrollMin
End Get
End Property
Public ReadOnly Property ScrollMax() As Integer
Get
Return Me.pnScrollMax
End Get
End Property
Public Sub ScrollWindow(ByVal tnChange As Integer)
Dim lnPosition As Integer = Me.ScrollPos + tnChange
If lnPosition < 0 Then
lnPosition = 0
ElseIf lnPosition > Me.ScrollMax - Me.ScrollPage + 1 Then
lnPosition = Me.ScrollMax - Me.ScrollPage + 1
End If
' Call SendMessage() to simulate movement of the ScrollBar (Reference:
http://www.vbcity.com/forums/topic.asp?tid=55822)
SendMessage(Me.Handle, WM_VSCROLL, SB_THUMBPOSITION + &H10000 * lnPosition,
Nothing)
End Sub
Private Sub MyTreeView_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Resize
' NOTE: Don't do anything with this event
' The below code causes the FullRowSelect property to not work properly
' So comment it out
'Me.RefreshScrollBarData()
End Sub
' Overriding WndProc() will allow you to intercept all of the messages
' that pass through the control. Use it to catch the scrolling events.
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
' This raises the ScrollChanged() event if any scroll action occurs,
' which keeps the custom ScrollBar with the TreeView's ScrollBar in sync
Me.RefreshScrollBarData()
End Sub
' Call this function to keep the custom ScrollBar with the TreeView's
ScrollBar in sync
Public Function RefreshScrollBarData() As SCROLLINFO
' Horizontal Scroll
Dim loHSI As New SCROLLINFO
loHSI.fMask = Me.SIF_ALL ' Set the fMask member to specify the scroll bar
parameters to retrieve
If GetScrollInfo(Me.Handle, Me.SBS_HORZ, loHSI) = 0 Then ' Non-zero
indicates success
If Me.IsHScrollVisible = True Then
RaiseEvent HScrollVisibleChanged(False)
Me.IsHScrollVisible = False
End If
Else
If loHSI.nPage > 0 And loHSI.nMax > 0 Then ' nPage must be > 0 for the
ScrollBar to be visible
If Me.IsHScrollVisible = False Then
RaiseEvent HScrollVisibleChanged(True)
Me.IsHScrollVisible = True
End If
Else
If Me.IsHScrollVisible = True Then
RaiseEvent HScrollVisibleChanged(False)
Me.IsHScrollVisible = False
End If
End If
End If
' Vertical Scroll
Dim loVSI As New SCROLLINFO
loVSI.fMask = SIF_ALL
If GetScrollInfo(Me.Handle, SBS_VERT, loVSI) = 0 Then
If Me.IsVScrollVisible Then
RaiseEvent VScrollVisibleChanged(False) ' Visibility has changed: True ->
False, raise event
Me.IsVScrollVisible = False
End If
Else
Dim llRaiseScrollChanged As Boolean = False
If loVSI.nPos <> Me.ScrollPos OrElse loVSI.nMax <> Me.ScrollMax OrElse
loVSI.nPage <> Me.ScrollPage Then
llRaiseScrollChanged = True ' Raise the ScrollChanged event if one of the
values have changed
End If
' Set the ScrollBar properties ---
Me.pnScrollPos = loVSI.nPos
Me.pnScrollPage = loVSI.nPage
Me.pnScrollMin = loVSI.nMin
Me.pnScrollMax = loVSI.nMax
'---------------------------------
If Me.ScrollMin = 0 AndAlso Me.ScrollMax = 0 Then
If Me.IsVScrollVisible Then
RaiseEvent VScrollVisibleChanged(False) ' Visibility has changed: True ->
False, raise event
Me.IsVScrollVisible = False
End If
Else
If Me.IsVScrollVisible = False Then
If loVSI.nPage > 0 And loVSI.nMax > 0 Then ' nPage must be > 0 for the
ScrollBar to be visible
RaiseEvent VScrollVisibleChanged(True) ' Visibility has changed: False ->
True, raise event
Me.IsVScrollVisible = True
End If
End If
If llRaiseScrollChanged Then
RaiseEvent ScrollChanged() ' Scroll values have changed, raise this event
End If
End If
End If
End Function
End Class
End Namespace
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uk*************@TK2MSFTNGP15.phx.gbl...
rh,
I see the image, but I am not sure what you want. The selection
crosses the full length of the control. How much longer do you want it to
extend?
Or do you mean the tool tip is showing up behind the form? I think
that is what you are referring to.
Is your app stand-alone (meaning no special database stuff, supporting
files, etc, etc). If so, can you post it?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"rh" <rh******@smci.com> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl... Please refer to the attached JPG image. Let me know if you also need the
see the code.
Thanks for any help.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:%2****************@TK2MSFTNGP09.phx.gbl... rh,
What do you mean by it appears behind the parent form? That says to
me
that you can't see the tree view at all.
Can you post a picture of what you mean, or some code that shows the
error (or an example we can run)?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"rh" <rh******@smci.com> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...
I created a user control that is made up of a TreeView and a VScrollBar.
I
set the TreeView.FullRowSelect = True and it works as expected (full row
is
visible, appears on top of everything else) but only sometimes. Other
times
it appears behind the parent form and all that is visible is the last
few
characters of that row.
Anyone know what might be causing this and how I can fix it? Thanks.