Jump to content

Hover tool tip for Tab items


aymhenry
 Share

Recommended Posts

Well here is the code:

Every item on the tab control has its own Tooltip value

#include <GUIConstantsEx.au3>
#Include <GuiTab.au3>

Opt('MustDeclareVars', 1)
Global $lngOldMousePos, $lngHoverTab

Example()

;---------------------------------------------------------------------------------------------------------
Func Example()
    Local $hTab, $msg, $frmGUI
    Local $lngLeftSide = 15
    
    $frmGUI = GUICreate("My GUI Tab", 300, 150); will create a dialog box that when displayed is centered
    GUISetFont (12)

;    GUISetBkColor(0x00E0FFFF)
;    GUISetFont(9, 300)

    $hTab = GUICtrlCreateTab($lngLeftSide, 10, 280, 100)

    GUICtrlCreateTabItem("Tab No.0")
        GUICtrlCreateLabel("label0", 30, 80, 50, 20)

    GUICtrlCreateTabItem("Tab No. 1")
        GUICtrlCreateLabel("label1", 30, 80, 50, 20)

    GUICtrlCreateTabItem("Tab No. 2")
        GUICtrlCreateLabel("label2", 30, 80, 50, 20)
        
    GUICtrlCreateTabItem("Tab No. 3")
    GUICtrlCreateTabItem("Tab No. 4")    
    GUICtrlCreateTabItem("Tab No. 5")
    
    GUICtrlCreateTabItem(""); end tabitem definition
    
    GUICtrlCreateLabel("Tool Tip for every Tab", 20, 130, 250, 20)

    GUISetState()

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        $lngHoverTab =  GUIGetHoverCursor (  $frmGUI , $hTab)
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example

;---------------------------------------------------------------------------------------------------------
Func GUIGetHoverCursor (  ByRef $frmGUI , ByRef $hTab)
    Local $nWidth, $nCurTab_Shift
    Local $a_MousePos = GUIGetCursorInfo  ($frmGUI)
    Local $nRel_TabNo
    Local $lng_CurrTabNo = _GUICtrlTab_GetCurSel ($hTab)

    If $lngOldMousePos =  $a_MousePos[0] Then ; save proceing time
        Return $lng_CurrTabNo
    Else
        $lngOldMousePos =  $a_MousePos[0]
    EndIf
    
        if $a_MousePos[4] = $hTab Then
            
            Local $a_CurPos = _GUICtrlTab_GetDisplayRect( GUICtrlGetHandle ($hTab))
            Local $a_CurTabPos = _GUICtrlTab_GetItemRect($hTab, $lng_CurrTabNo)
            
            $nWidth = $a_CurTabPos [2] - $a_CurTabPos [0]
            $nCurTab_Shift = $lng_CurrTabNo - Int ( ( $a_CurTabPos [0] - 2 ) / $nWidth )
            
            $nRel_TabNo = Int( ($a_MousePos[0] - $a_CurPos[0] )/$nWidth) + $nCurTab_Shift 
            
            if $a_CurTabPos[3] >= $a_MousePos[1] then
                ToolTip  ( "Item " & $nRel_TabNo)
            Else    
                ToolTip ("")    
            EndIf    
        Else
            ToolTip ("")    
            $nRel_TabNo = $nCurTab_Shift
        EndIf
        
        
    Return $nRel_TabNo    
EndFunc
;---------------------------------------------------------------------------------------------------------
Link to comment
Share on other sites

Mmmh,

works good. Alternatively you could use that direct from the help-example

_GUICtrlTab_SetToolTips($hWnd, $hToolTip)

which may less work.

best regards, Reinhard

I read this  in help file but, this one works for all the tab control

The program gives every item on the tab control a unique  tool tip

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...