dcsimg
Results 1 to 6 of 6

Thread: Class cToolTip and statusbar

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    1,925

    Class cToolTip and statusbar

    Code:
    Private Sub StatusBar1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    
        If Not m_bInLable Then
            m_bInLable = True
            TT.Title = "INFO!"
            TT.TipText = "NUMERO SPORTELLI ATTIVI"
            TT.Create Me.StatusBar1.hWnd
        End If
    
    End Sub
    naturally this code show baloon on all part of StatusBar1 zone.

    i need to show the baloon tips only on panel(7) of StatusBar1...

    possible?
    Tks.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,525

    Re: Class cToolTip and statusbar

    I would think that you would want to a custom hit test on which panel the mouse is over. That should be easy enough since each panel has a left & width property. Pseudocode follows
    Code:
       Dim bCreateTTip As Boolean
     ...
       If X > Panel(7).Left Then
          If X < Panel(7).Left + Panel(7).Width Then
             bCreateTTip
         End If
       End If
       If bCreateTTip Then
          ' if tooltip does not exist yet, create it
       Else
          ' if tooltip exists, clear it
       End If
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    284

    Re: Class cToolTip and statusbar

    Similar logic as above, but also takes the StatusBar's Container ScaleMode into account (the StatusBar's MouseMove X & Y always seems to be in Twips, but the Panel's Left & Width are in the Container's ScaleMode):

    Code:
    Private Sub StatusBar1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        On Error Resume Next
        If GetPanelOver(StatusBar1, X).Index <> 7 Then
            On Error GoTo 0
            TT.Destroy Me.StatusBar1.hWnd       '<-- If cToolTip has a Destroy or similar method, call it here
        Else
            On Error GoTo 0
            TT.Title = "INFO!"
            TT.TipText = "NUMERO SPORTELLI ATTIVI"
            TT.Create Me.StatusBar1.hWnd
        End If
    End Sub
    
    Private Function GetPanelOver(ByRef SB As StatusBar, ByVal X As Single) As Panel
        With SB.Container
            On Error Resume Next                'Some Containers might not expose a ScaleMode property
            X = .ScaleX(X, vbTwips, .ScaleMode) 'Just assume Twips in that case
            On Error GoTo 0                     'X won't need scaling then
        End With
    
        X = X + SB.Left                         'The StatusBar might not be aligned to any side, so take into account StatusBar.Left
    
        For Each GetPanelOver In SB.Panels
            With GetPanelOver
                If .Left <= X Then If X < .Left + .Width Then Exit Function
            End With
        Next
    End Function

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    1,925

    Re: Class cToolTip and statusbar

    Quote Originally Posted by Victor Bravo VI View Post
    Similar logic as above, but also takes the StatusBar's Container ScaleMode into account (the StatusBar's MouseMove X & Y always seems to be in Twips, but the Panel's Left & Width are in the Container's ScaleMode):

    Code:
    Private Sub StatusBar1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        On Error Resume Next
        If GetPanelOver(StatusBar1, X).Index <> 7 Then
            On Error GoTo 0
            TT.Destroy Me.StatusBar1.hWnd       '<-- If cToolTip has a Destroy or similar method, call it here
        Else
            On Error GoTo 0
            TT.Title = "INFO!"
            TT.TipText = "NUMERO SPORTELLI ATTIVI"
            TT.Create Me.StatusBar1.hWnd
        End If
    End Sub
    
    Private Function GetPanelOver(ByRef SB As StatusBar, ByVal X As Single) As Panel
        With SB.Container
            On Error Resume Next                'Some Containers might not expose a ScaleMode property
            X = .ScaleX(X, vbTwips, .ScaleMode) 'Just assume Twips in that case
            On Error GoTo 0                     'X won't need scaling then
        End With
    
        X = X + SB.Left                         'The StatusBar might not be aligned to any side, so take into account StatusBar.Left
    
        For Each GetPanelOver In SB.Panels
            With GetPanelOver
                If .Left <= X Then If X < .Left + .Width Then Exit Function
            End With
        Next
    End Function
    WORK!

    but i have see my project with attention...

    i need the same effect also for panel(1) and panel(2). (With a case select, i think).

    for panel(7) the actual TT.TipText = "NUMERO SPORTELLI ATTIVI", for panel(1) TT.TipText = "NUMERO ABI ATTIVI", for panel(2) TT.TipText = "NUMERO CAB CHIUSI"


    Possible?
    Last edited by luca90; Nov 10th, 2019 at 02:54 PM.

  5. #5
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    284

    Re: Class cToolTip and statusbar

    Quote Originally Posted by luca90 View Post
    (With a case select, i think).
    Yep, you got that right.

    Code:
    Private Sub StatusBar1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim I As Integer
    
        On Error Resume Next
        I = GetPanelOver(StatusBar1, X).Index
        On Error GoTo 0
    
        Select Case I
            Case 1:     TT.TipText = "NUMERO ABI ATTIVI"
            Case 2:     TT.TipText = "NUMERO CAB CHIUSI"
            Case 7:     TT.TipText = "NUMERO SPORTELLI ATTIVI"
            Case Else:  TT.Destroy Me.StatusBar1.hWnd:          Exit Sub
        End Select
    
        TT.Title = "INFO!"
        TT.Create Me.StatusBar1.hWnd
    End Sub

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    1,925

    Re: Class cToolTip and statusbar

    Quote Originally Posted by Victor Bravo VI View Post
    Yep, you got that right.

    Code:
    Private Sub StatusBar1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim I As Integer
    
        On Error Resume Next
        I = GetPanelOver(StatusBar1, X).Index
        On Error GoTo 0
    
        Select Case I
            Case 1:     TT.TipText = "NUMERO ABI ATTIVI"
            Case 2:     TT.TipText = "NUMERO CAB CHIUSI"
            Case 7:     TT.TipText = "NUMERO SPORTELLI ATTIVI"
            Case Else:  TT.Destroy Me.StatusBar1.hWnd:          Exit Sub
        End Select
    
        TT.Title = "INFO!"
        TT.Create Me.StatusBar1.hWnd
    End Sub
    tks Victor Bravo!
    I can test it only tomorrow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width