Jump to content

ToolTip and Statusbar text change when mouse cursor over a dropdown menu


Aciano
 Share

Recommended Posts

Hi. Can anyone clue me in on how to show ToolTip on a dropdown menu item and how to change Statusbar text when mouse cursor is over a dropdown menu item? It would be highly appreciated and probably helpful for others, I did some searching, but couldn't find it here. Txs

Link to comment
Share on other sites

  • Moderators

Hi. Can anyone clue me in on how to show ToolTip on a dropdown menu item and how to change Statusbar text when mouse cursor is over a dropdown menu item? It would be highly appreciated and probably helpful for others, I did some searching, but couldn't find it here. Txs

Have any code for us to work with or do we make our own :wacko::D

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

#include <guiconstants.au3>

$Winhl = GUICreate('TITLE', 400, 285)

Global $defaultstatus = "Ready"
Global $status

$filemenu = GUICtrlCreateMenu("&File")
$file1 = GUICtrlCreateMenuitem("Label 1", $filemenu)
$file2 = GUICtrlCreateMenuitem("Label 2", $filemenu)
$file8 = GUICtrlCreateMenuitem("Label 3", $filemenu)
$file9 = GUICtrlCreateMenuitem("Label 4", $filemenu)

$statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 250, 400, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
            
    EndSelect
WEnd
Exit

Here is something you can start with. If possible try to make it both in one GUI. Txs for such fast response.

Link to comment
Share on other sites

  • Moderators

Wow, this is a job for someone that knows GUIRegisterMsg() pretty well, I can't get the handle of the sub menus so there's not much I can do, If I could have, I would have been able to fix the statusbar thing too....

I'm looking over Holgers stuff now on icon placement seeing if there's anything I can steal from there :D, but I'm afraid the hours have surpassed my brain at the moment, so I don't think I'm going to be much help :wacko:

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Smoke - at least you tried... so that is what I thought. If it was not hard I would more likely figure it out myself. I even thought about Mouse functions, but I didnt came up with anything.

Wouldn't really work without pixel functions that way, but that's not how it should be done, I know if you can make a sub menu have a sub menu, then you can obviously get the handle of the damn thing... I'm just too tired to figure out how... I thought I had it 5 minutes ago... but then I woke up :D

Edit:

And GUIGetMsg() pics it up... so... let me try another thing.

Edit2:

Nope... Sorry man! Hope you get it... I'd like to know now as well.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

You can try the following code. I assume your running beta.

;Menu Help
;Stephen Podhajecki [eltorro] gehossafats@netmdc.com

#Include <GuiConstants.au3>
#include <Array.au3>
Global $USE_TOOLTIP = TRUE
Global $DEBUG = True

Local $aCtrlArray[1], $aCtrlMsgArray[1],$ControlID, $Global_I = 0, $__ControlID, $HoverActive = 0, $Temp_Found = 0, $szTemp_Array[2]

Global $defaultstatus = "Ready"
Global $status
Global $Timer

Global Const $WM_MENUSELECT = 0x011F
GUIRegisterMsg($WM_MENUSELECT,"MouseOverMenu")

$Form1 = GUICreate('TITLE', 400, 285)
$filemenu = GUICtrlCreateMenu("&File")
_AddCtrl($filemenu,"FileMenu")
$file1 = GUICtrlCreateMenuitem("Label 1", $filemenu)
_AddCtrl($file1,"This is Label1")
$file2 = GUICtrlCreateMenuitem("Label 2", $filemenu)
_AddCtrl($file2,"Label 2 at Your Service")
$file3 = GUICtrlCreateMenuitem("Label3", $filemenu)
_AddCtrl($file3,"Pleased to meet you from Label 3")
$file4 = GUICtrlCreateMenuitem("Label 4", $filemenu)
_AddCtrl($file4,"Well, you get the picture, Label 4")
$statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 250, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))
$statuslabel2 =GUICtrlCreateLabel($defaultstatus, 300, 250, 100, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))
$file11= GUICtrlCreateMenuitem("Label 11",$file1)
GUISetState()
While 1
    $msg = GUIGetMsg()
     Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $file1
            MsgBox(266288,"Menu Clicked","Label1 clicked.")
    EndSelect
;~     $t_Sec = int( TimerDiff($Timer)/1000)
;~     ;if $t_Sec = int($t_Sec) then 
;~         GuiCtrlSetData($statuslabel2,$t_Sec)
;~     ;EndIf
;~     
;~     if TimerDiff($Timer) >3000 Then ToolTip("")
WEnd
Exit

Func MouseOverMenu($hWndGUI, $MsgID, $WParam, $LParam)
if $DEBUG  then ConsoleWrite( "hWndGui= "&$hWndGUI& @LF &"MsgId= "&$MsgID& @LF &"WParam= " &$WParam& @LF &"$LParam= "&$LParam& @LF)
Local $id = BitAnd($WParam, 0xFFFF)
if $DEBUG  then ConsoleWrite("ID= "& $id & @LF)

for $x= 0 to UBound($aCtrlArray)-1
    if $id = ($aCtrlArray[$x]) then 
        GuiCtrlSetData($statuslabel , $aCtrlMsgArray[$x])
        if $USE_TOOLTIP then ToolTip($aCtrlMsgArray[$x])
;~         $Timer = TimerInit()
        ExitLoop
    EndIf
Next
Return $GUI_RUNDEFMSG
EndFunc

Func _AddCtrl($ControlID,$ControlMsg)
    _ArrayAdd($aCtrlArray,$ControlID)
    _ArrayAdd($aCtrlMsgArray,$ControlMsg)
EndFunc

Regards

Link to comment
Share on other sites

  • Moderators

You can try the following code. I assume your running beta.

;Menu Help
;Stephen Podhajecki [eltorro] gehossafats@netmdc.com

#Include <GuiConstants.au3>
#include <Array.au3>
Global $USE_TOOLTIP = TRUE
Global $DEBUG = True

Local $aCtrlArray[1], $aCtrlMsgArray[1],$ControlID, $Global_I = 0, $__ControlID, $HoverActive = 0, $Temp_Found = 0, $szTemp_Array[2]

Global $defaultstatus = "Ready"
Global $status
Global $Timer

Global Const $WM_MENUSELECT = 0x011F
GUIRegisterMsg($WM_MENUSELECT,"MouseOverMenu")

$Form1 = GUICreate('TITLE', 400, 285)
$filemenu = GUICtrlCreateMenu("&File")
_AddCtrl($filemenu,"FileMenu")
$file1 = GUICtrlCreateMenuitem("Label 1", $filemenu)
_AddCtrl($file1,"This is Label1")
$file2 = GUICtrlCreateMenuitem("Label 2", $filemenu)
_AddCtrl($file2,"Label 2 at Your Service")
$file3 = GUICtrlCreateMenuitem("Label3", $filemenu)
_AddCtrl($file3,"Pleased to meet you from Label 3")
$file4 = GUICtrlCreateMenuitem("Label 4", $filemenu)
_AddCtrl($file4,"Well, you get the picture, Label 4")
$statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 250, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))
$statuslabel2 =GUICtrlCreateLabel($defaultstatus, 300, 250, 100, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))
$file11= GUICtrlCreateMenuitem("Label 11",$file1)
GUISetState()
While 1
    $msg = GUIGetMsg()
     Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $file1
            MsgBox(266288,"Menu Clicked","Label1 clicked.")
    EndSelect
;~     $t_Sec = int( TimerDiff($Timer)/1000)
;~     ;if $t_Sec = int($t_Sec) then 
;~         GuiCtrlSetData($statuslabel2,$t_Sec)
;~     ;EndIf
;~     
;~     if TimerDiff($Timer) >3000 Then ToolTip("")
WEnd
Exit

Func MouseOverMenu($hWndGUI, $MsgID, $WParam, $LParam)
if $DEBUG  then ConsoleWrite( "hWndGui= "&$hWndGUI& @LF &"MsgId= "&$MsgID& @LF &"WParam= " &$WParam& @LF &"$LParam= "&$LParam& @LF)
Local $id = BitAnd($WParam, 0xFFFF)
if $DEBUG  then ConsoleWrite("ID= "& $id & @LF)

for $x= 0 to UBound($aCtrlArray)-1
    if $id = ($aCtrlArray[$x]) then 
        GuiCtrlSetData($statuslabel , $aCtrlMsgArray[$x])
        if $USE_TOOLTIP then ToolTip($aCtrlMsgArray[$x])
;~         $Timer = TimerInit()
        ExitLoop
    EndIf
Next
Return $GUI_RUNDEFMSG
EndFunc

Func _AddCtrl($ControlID,$ControlMsg)
    _ArrayAdd($aCtrlArray,$ControlID)
    _ArrayAdd($aCtrlMsgArray,$ControlMsg)
EndFunc

Regards

That's super nice eltorro!!... got one for buttons? :D

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

That's super nice eltorro!!... got one for buttons? :D

I already did one for buttons

Edit: have a look

#include <GUIConstants.au3>
Opt("MustDeclareVars", 1)

Global Const $DebugIt = 1
Global Const $WM_NOTIFY = 0x004E
Global Const $BCN_HOTITEMCHANGE = -1249
Global $Hovered = 0
Global $Button[13][2], $status

_Main()

Func _Main()
    Local $x = 48, $y = 88, $msg, $Form2
    
    Local $SetStatus[13] = [12, "Open Notepad, for text editing.", "Open MSPaint, for basic photo editing.", "Open Regedit, for regestry editing.", _
            "Open The Gimp, for Photo manipulation, and editing.", "Open My Computer, for no particular reason.", "Nothing yet", "Nothing yet", "Nothing yet", _
            "Nothing yet", "Nothing yet", "Nothing yet", "Nothing yet"]
    Local $Btn_Text[13] = [12, "Notepad", "MSpaint", "Regedit", "The Gimp", "My Computer", _
            "AButton1", "AButton1", "AButton1", "AButton1", "AButton1", "AButton1", "AButton1"]
    
    $Form2 = GUICreate("Blash", 716, 561, 155, 134, BitOR($WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_TABSTOP))
    $status = GUICtrlCreateLabel("Welcome to Blash", 24, 528, 651, 17)
    
    $Button[0][0] = 12
    
    For $i = 1 To 6
        $Button[$i][0] = GUICtrlCreateButton($Btn_Text[$i], $x, $y, 89, 41)
        $Button[$i][1] = $SetStatus[$i]
        $Button[$i + 6][0] = GUICtrlCreateButton($Btn_Text[$i + 6], $x, $y + 64, 89, 41)
        $Button[$i + 6][1] = $SetStatus[$i + 6]
        $x += 104
    Next
    ;Register WM_NOTIFY  events
    GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
    GUISetState(@SW_SHOW)
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case Else
                For $x = 1 To $Button[0][0]
                    If $msg = $Button[$x][0] Then
                        ; do something, could be another array
                        ExitLoop
                    EndIf
                Next
        EndSelect
    WEnd
EndFunc   ;==>_Main

; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local Const $HICF_ENTERING = 0x10
    Local Const $HICF_LEAVING = 0x20
    Local $tagNMBCHOTITEM, $event, $hwndFrom, $code, $dwFlags, $i
    $tagNMBCHOTITEM = DllStructCreate("int;int;int;dword", $lParam)
    $hwndFrom = DllStructGetData($tagNMBCHOTITEM, 1)
    $code = DllStructGetData($tagNMBCHOTITEM, 3)
    $dwFlags = DllStructGetData($tagNMBCHOTITEM, 4)
    Select
        Case $code = $BCN_HOTITEMCHANGE
            ;----------------------------------------------------------------------------------------------
            If $DebugIt Then    _DebugPrint ("$BCN_HOTITEMCHANGE")
            ;----------------------------------------------------------------------------------------------
            If BitAND($dwFlags, $HICF_LEAVING) = $HICF_LEAVING Then
                ;----------------------------------------------------------------------------------------------
                If $DebugIt Then    _DebugPrint ("Leaving" & @LF & "Button Area")
                ;----------------------------------------------------------------------------------------------
                GUICtrlSetData($status, "Welcome to Blash")
            ElseIf BitAND($dwFlags, $HICF_ENTERING) = $HICF_ENTERING Then
                ;----------------------------------------------------------------------------------------------
                If $DebugIt Then    _DebugPrint ("Entering" & @LF & "Button Area")
                ;----------------------------------------------------------------------------------------------
                For $i = 1 To $Button[0][0]
                    If $hwndFrom = ControlGetHandle($hWndGUI, "", $Button[$i][0]) Then
                        GUICtrlSetData($status, $Button[$i][1])
                        ExitLoop
                    EndIf
                Next
            EndIf
    EndSelect
    $tagNMBCHOTITEM = 0
    $event = 0
    $lParam = 0
EndFunc   ;==>WM_Notify_Events

Func _DebugPrint($s_text)
    $s_text = StringReplace($s_text, @LF, @LF & "-->")
    ConsoleWrite( _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF)
EndFunc   ;==>_DebugPrint
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • Moderators

good going man!

see also marfdamans' mousehover udf: http://www.autoitscript.com/forum/index.php?showtopic=28714

That's what I was trying to avoid, he's using AdlibEnable :wacko:, didn't want to do that. Thanks Gary!

Edit:

Dammit Gary, I worked on this one too with a different approach I remember, I couldn't remember where it was though!! :D

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

That's what I was trying to avoid, he's using AdlibEnable :wacko:, didn't want to do that. Thanks Gary!

Edit:

Dammit Gary, I worked on this one too with a different approach I remember, I couldn't remember where it was though!! :D

@Aciano, sorry don't mean to hi-jack your thread, was just answering a question.

@SmOke_N NP, here's a little more meat for you to chew on

#include <GUIConstants.au3>
Opt("MustDeclareVars", 1)

Global Const $DebugIt = 1
Global Const $WM_NOTIFY = 0x004E
Global Const $WM_COMMAND = 0x0111
Global $Hovered = 0
Global $Button[13][2], $status

_Main()

Func _Main()
    Local $x = 48, $y = 88, $msg, $Form2
    
    Local $SetStatus[13] = [12, "Open Notepad, for text editing.", "Open MSPaint, for basic photo editing.", "Open Regedit, for regestry editing.", _
            "Open The Gimp, for Photo manipulation, and editing.", "Open My Computer, for no particular reason.", "Nothing yet", "Nothing yet", "Nothing yet", _
            "Nothing yet", "Nothing yet", "Nothing yet", "Nothing yet"]
    Local $Btn_Text[13] = [12, "Notepad", "MSpaint", "Regedit", "The Gimp", "My Computer", _
            "AButton1", "AButton1", "AButton1", "AButton1", "AButton1", "AButton1", "AButton1"]
    
    $Form2 = GUICreate("Blash", 716, 561, 155, 134, BitOR($WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_TABSTOP))
    $status = GUICtrlCreateLabel("Welcome to Blash", 24, 528, 651, 17)
    
    $Button[0][0] = 12
    
    For $i = 1 To 6
        $Button[$i][0] = GUICtrlCreateButton($Btn_Text[$i], $x, $y, 89, 41)
        $Button[$i][1] = $SetStatus[$i]
        $Button[$i + 6][0] = GUICtrlCreateButton($Btn_Text[$i + 6], $x, $y + 64, 89, 41)
        $Button[$i + 6][1] = $SetStatus[$i + 6]
        $x += 104
    Next
    ;Register WM_NOTIFY  events
    GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
    GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
    GUISetState(@SW_SHOW)
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
        EndSelect
    WEnd
EndFunc   ;==>_Main

Func Button_Click(ByRef $ctrl_id)
    For $i = 1 To $Button[0][0]
        If $ctrl_id = $Button[$i][0] Then
            _DebugPrint("Button: " & $Button[$i][0])
            ExitLoop
        EndIf
    Next
EndFunc   ;==>Button_Click

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc   ;==>_LoWord

Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc   ;==>_HiWord

; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local Const $BCN_HOTITEMCHANGE = -1249
    Local Const $HICF_ENTERING = 0x10
    Local Const $HICF_LEAVING = 0x20
    Local $tagNMBCHOTITEM, $event, $hwndFrom, $code, $dwFlags, $i
    $tagNMBCHOTITEM = DllStructCreate("int;int;int;dword", $lParam)
    $hwndFrom = DllStructGetData($tagNMBCHOTITEM, 1)
    $code = DllStructGetData($tagNMBCHOTITEM, 3)
    $dwFlags = DllStructGetData($tagNMBCHOTITEM, 4)
    Select
        Case $code = $BCN_HOTITEMCHANGE
            ;----------------------------------------------------------------------------------------------
            If $DebugIt Then    _DebugPrint ("$BCN_HOTITEMCHANGE")
            ;----------------------------------------------------------------------------------------------
            If BitAND($dwFlags, $HICF_LEAVING) = $HICF_LEAVING Then
                ;----------------------------------------------------------------------------------------------
                If $DebugIt Then    _DebugPrint ("Leaving" & @LF & "Button Area")
                ;----------------------------------------------------------------------------------------------
                GUICtrlSetData($status, "Welcome to Blash")
            ElseIf BitAND($dwFlags, $HICF_ENTERING) = $HICF_ENTERING Then
                ;----------------------------------------------------------------------------------------------
                If $DebugIt Then    _DebugPrint ("Entering" & @LF & "Button Area")
                ;----------------------------------------------------------------------------------------------
                For $i = 1 To $Button[0][0]
                    If $hwndFrom = ControlGetHandle($hWndGUI, "", $Button[$i][0]) Then
                        GUICtrlSetData($status, $Button[$i][1])
                        ExitLoop
                    EndIf
                Next
            EndIf
    EndSelect
    $tagNMBCHOTITEM = 0
    $event = 0
    $lParam = 0
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_Notify_Events

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local Const $BN_CLICKED = 0;
    Local Const $BN_PAINT = 1;
    Local Const $BN_HILITE = 2;
    Local Const $BN_PUSHED = $BN_HILITE;
    Local Const $BN_UNHILITE = 3;
    Local Const $BN_UNPUSHED = $BN_UNHILITE;
    Local Const $BN_DISABLE = 4;
    Local Const $BN_DOUBLECLICKED = 5;
    Local Const $BN_DBLCLK = $BN_DOUBLECLICKED;
    Local Const $BN_SETFOCUS = 6;
    Local Const $BN_KILLFOCUS = 7;
    Local $nNotifyCode = _HiWord($wParam)
    Local $nID = _LoWord($wParam)
    Local $hCtrl = $lParam

    
    If $nID <> 2 Then
        Switch $nNotifyCode
            Case $BN_CLICKED
                _DebugPrint("$BN_CLICKED: " & @LF & "GUIHWnd" & @TAB & ":" & $hwnd & @LF & _
                                                "MsgID" & @TAB & ":" & $Msg & @LF & _
                                                "wParam" & @TAB & ":" & $wParam & @LF & _
                                                "lParam" & @TAB & ":" & $lParam & @LF & @LF & _
                                                "WM_COMMAND - Infos:" & @LF & _
                                                "-----------------------------" & @LF & _
                                                "Code" & @TAB & ":" & $nNotifyCode & @LF & _
                                                "CtrlID" & @TAB & ":" & $nID & @LF & _
                                                "CtrlHWnd" & @TAB & ":" & $hCtrl)
                    Button_Click ($nID)
            Case $BN_PAINT
                _DebugPrint("$BN_PAINT")
            Case $BN_PUSHED, $BN_HILITE
                _DebugPrint("$BN_PUSHED, $BN_HILITE")
            Case $BN_UNPUSHED, $BN_UNHILITE
                _DebugPrint("$BN_UNPUSHED")
            Case $BN_DISABLE
                _DebugPrint("$BN_DISABLE")
            Case $BN_DBLCLK, $BN_DOUBLECLICKED
                _DebugPrint("$BN_DBLCLK, $BN_DOUBLECLICKED")
            Case $BN_SETFOCUS
                _DebugPrint("$BN_SETFOCUS")
            Case $BN_KILLFOCUS
                _DebugPrint("$BN_KILLFOCUS")
        EndSwitch
    EndIf
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND

Func _DebugPrint($s_text)
    $s_text = StringReplace($s_text, @LF, @LF & "-->")
    ConsoleWrite( _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF)
EndFunc   ;==>_DebugPrint
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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...