Mouseover inkl. Tabitem

  • Hallo zusammen,


    ich habe mich ein wenig an dem "MouseoverTooltip" von chrisatack versucht. Zusätzlich habe ich noch 3 ItemTabs eingefügt inkl. Buttons.

    Nun ist es leider so das die "Tooltips" aller Button (auch bei nicht aktivem Tab) angezeigt werden solbald die Mouse die Koordinaten erreicht.

    Es soll aber nur den "Tooltip" des jeweiligen Tabs anzeigen....ist das möglich ??


    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    $wintitel = "Form1"
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 400,400)
    GuiCtrlCreateTab(5, 5, 380, 380)
    GuiCtrlCreateTabItem("Tab 1")
    $Button1 = GUICtrlCreateButton("exit", 10, 100, 61, 31, 0)
    GuiCtrlCreateTabItem("Tab 2")
    $Button2 = GUICtrlCreateButton("exit", 100, 100, 61, 31, 0)
    GuiCtrlCreateTabItem("Tab 2")
    $Button2 = GUICtrlCreateButton("exit", 200, 100, 61, 31, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    Exit
    EndSwitch
    _Tooltip()
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]


    Func _MouseOver($_mo_x, $_mo_y, $_mo_width, $_mo_height)
    If WinActive($wintitel) = 1 Then ; WICHTIG!!!!! NUR WENN DAS FENSTER AKTIV IST MOUSOVER PRÜFEN
    $_mo_pos = GUIGetCursorInfo()
    If ($_mo_pos[0] > $_mo_x) and ($_mo_pos[0] < $_mo_x + $_mo_width) and ($_mo_pos[1] > $_mo_y) and ($_mo_pos[1] < $_mo_y + $_mo_height) Then
    Return 1
    Else
    Return 0
    EndIf
    EndIf
    EndFunc

    Func _Tooltip()
    $tooltip_sleep = '50'

    ;Spieler1-----------------------------------------------------------------------------
    If _MouseOver(10, 100, 61, 31) = 1 Then
    Do
    ToolTip ("Button Tab 1",Default,Default,'Test1',1)
    Sleep($tooltip_sleep)
    Until _MouseOver(10, 100, 61, 31) = 0
    ToolTip('')
    EndIf

    ;Name2-----------------------------------------------------------------------------
    If _MouseOver(100, 100, 61, 31) = 1 Then
    Do
    ToolTip ("Button Tab 2",Default,Default,'Test 2',1)
    Sleep($tooltip_sleep)
    Until _MouseOver(100, 100, 61, 31) = 0
    ToolTip('')
    EndIf

    ;Name3-----------------------------------------------------------------------------
    If _MouseOver(200, 100, 61, 31) = 1 Then
    Do
    ToolTip ("Button Tab 3",Default,Default,'Test 3',1)
    Sleep($tooltip_sleep)
    Until _MouseOver(200, 100, 61, 31) = 0
    ToolTip('')
    EndIf
    EndFunc

    [/autoit]
  • Hallo Apocsis,

    du könntest mit WinSetTitle zum Ziel kommen. Probier dazu mal das Beispiel aus der Hilfe zu GUICtrlCreateTabItem. Am besten baust du dort die Funktionen von Chrisatack ein und schaust ob es das ist was du suchst.

    mfg (Auto)Bert

    • Offizieller Beitrag

    Du mußt nur das aktive TabItem abfragen und in der Auswertung überprüfen.
    Habe es mal angepaßt.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #Include <GuiTab.au3>
    Global $Tab

    [/autoit] [autoit][/autoit] [autoit]

    $wintitel = "Form1"
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 400,400)
    $Tab = GuiCtrlCreateTab(5, 5, 380, 380)
    GuiCtrlCreateTabItem("Tab 1")
    $Button1 = GUICtrlCreateButton("exit", 10, 100, 61, 31, 0)
    GuiCtrlCreateTabItem("Tab 2")
    $Button2 = GUICtrlCreateButton("exit", 100, 100, 61, 31, 0)
    GuiCtrlCreateTabItem("Tab 2")
    $Button2 = GUICtrlCreateButton("exit", 200, 100, 61, 31, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    Exit
    EndSwitch
    _Tooltip()
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _MouseOver($_mo_x, $_mo_y, $_mo_width, $_mo_height)
    If Not WinActive($wintitel) Then Return ; WICHTIG!!!!! NUR WENN DAS FENSTER AKTIV IST MOUSOVER PRÜFEN
    $_mo_pos = GUIGetCursorInfo()
    If ($_mo_pos[0] > $_mo_x) and ($_mo_pos[0] < $_mo_x + $_mo_width) and ($_mo_pos[1] > $_mo_y) and _
    ($_mo_pos[1] < $_mo_y + $_mo_height) Then Return 1
    Return 0
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _Tooltip()
    $currTab = _GUICtrlTab_GetCurSel($Tab)
    $tooltip_sleep = '50'
    ;Spieler1-----------------------------------------------------------------------------
    If _MouseOver(10, 100, 61, 31) And $currTab = 0 Then
    Do
    ToolTip ("Button Tab 1",Default,Default,'Test1',1)
    Sleep($tooltip_sleep)
    Until _MouseOver(10, 100, 61, 31) = 0
    ToolTip('')
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;Name2-----------------------------------------------------------------------------
    If _MouseOver(100, 100, 61, 31) And $currTab = 1 Then
    Do
    ToolTip ("Button Tab 2",Default,Default,'Test 2',1)
    Sleep($tooltip_sleep)
    Until _MouseOver(100, 100, 61, 31) = 0
    ToolTip('')
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;Name3-----------------------------------------------------------------------------
    If _MouseOver(200, 100, 61, 31) And $currTab = 2 Then
    Do
    ToolTip ("Button Tab 3",Default,Default,'Test 3',1)
    Sleep($tooltip_sleep)
    Until _MouseOver(200, 100, 61, 31) = 0
    ToolTip('')
    EndIf
    EndFunc

    [/autoit]

    Edit:
    Ich hab dir mal die Funktion _Tooltip() noch 'verschlankt'. ;)


    [autoit]

    Func _Tooltip()
    $currTab = _GUICtrlTab_GetCurSel($Tab)
    $tooltip_sleep = '50'
    Local $aButton[3][6] = [[10,100,61,31,'Button Tab 1','Test1'],[100,100,61,31,'Button Tab 2','Test2'],[200,100,61,31,'Button Tab 3','Test3']]
    If _MouseOver($aButton[$currTab][0], $aButton[$currTab][1], $aButton[$currTab][2], $aButton[$currTab][3]) Then
    Do
    ToolTip ($aButton[$currTab][4],Default,Default,$aButton[$currTab][5],1)
    Sleep($tooltip_sleep)
    Until Not _MouseOver($aButton[$currTab][0], $aButton[$currTab][1], $aButton[$currTab][2], $aButton[$currTab][3])
    ToolTip('')
    EndIf
    EndFunc

    [/autoit]