Re: Timing ToolTip on ContextMenu
"valery_vi" <[email protected]>
| Newsgroups | gmane.comp.windows.autoit.user |
|---|---|
| Message-ID | <[email protected]> |
Important note: To close only tooltip (context menu will be visible)
you should replace (in body of Func func_DetectIdle) line
WinClose ("classname=#32768")
to these ones
; WinClose ("classname=#32768")
ToolTip('')
Valery
--- In [email protected], "valery_vi" <shehrer1@...> wrote:
>
> Sunaj from AutoItScript forum is exploring one interesting thing
>
> How to close tooltip when user moved the mouse off the context
menu?
>
> http://www.autoitscript.com/forum/index.php?showtopic=38382
>
> This is his version with my update of
> Func func_DetectIdle($hWndGUI, $MsgID, $WParam, $LParam)
> It works fine for me.
>
>
> ;http://msdn.microsoft.com/msdnmag/issues/03/11/CQA/
> #include <GuiConstants.au3>
> #include <Array.au3>
>
> Opt("GUIOnEventMode", 1)
> Opt("WinTitleMatchMode", 4)
>
> ;$USE_TOOLTIP = True
> Global Const $WM_ENTERIDLE = 0x0121
> Global Const $WM_MENUSELECT = 0x011F
> Global Const $WM_SYSCOMMAND = 0x112 ; works on exit, minimize,
> questionsmark..etc.
>
> GUIRegisterMsg($WM_MENUSELECT,"func_MouseOverMenu")
> GUIRegisterMsg($WM_ENTERIDLE,"func_DetectIdle")
> Dim $a_CtrlIDArray[1],$a_CtrlMsgArray[1],$USE_TOOLTIP =
> TRUE,$WParam,$LParam
>
> $hGui_Main = GUICreate('Demo', 400, 285)
> $hContextmenu = GUICtrlCreateContextMenu () ; do i need to use
a
> Auto3Lib native call here?
> $hFileitem = GUICtrlCreateMenuitem ("Open", $hContextmenu)
> func_AddToolTipCtrl($hFileitem,"Works in context
> menuitem '$hFileitem' as well!")
> $hSaveitem = GUICtrlCreateMenuitem ("Save", $hContextmenu)
> func_AddToolTipCtrl($hSaveitem,"Works in context
> menuitem '$hSaveitem' as well!")
> $hInfoitem = GUICtrlCreateMenuitem ("Info", $hContextmenu)
> func_AddToolTipCtrl($hInfoitem,"Works in context
> menuitem '$hInfoitem' as well!")
>
> GUISetOnEvent($GUI_EVENT_CLOSE, "func_Exit")
> GUISetState()
>
> While 1
> Sleep(333)
> WEnd
>
> Func func_MouseOverMenu($hWndGUI, $MsgID,$WParam,$LParam)
> For $i = 0 To UBound($a_CtrlIDArray) - 1
> ; see
> http://tols17.oulu.fi/~vtatila/ohjy/english/ohjy38.html
> If ($a_CtrlIDArray[$i]) = BitAnd($WParam, 0xFFFF) Then
> ;ConsoleWrite("$WParam: " & $WParam & @CRLF)
> ;ConsoleWrite("$LParam: " & $LParam & @CRLF)
> ;ConsoleWrite("BitAnd($WParam, 0xFFFF): " & BitAnd
> ($WParam, 0xFFFF) & @CRLF)
> ;ConsoleWrite("$a_CtrlIDArray[$i]: " & $a_CtrlIDArray
> [$i] & @CRLF)
> ToolTip($a_CtrlMsgArray[$i])
> ExitLoop
> EndIf
> Next
> EndFunc
>
> ;Close tooltip when user moved the mouse off the context menu
> Func func_DetectIdle($hWndGUI, $MsgID, $WParam, $LParam)
> local $WinPos, $MousePos
> if WinExists ("classname=#32768") then
> $WinPos = WinGetPos("classname=#32768")
> $MousePos = MouseGetPos()
> if $MousePos[0] < $WinPos[0] or $MousePos[1] <
> $WinPos[1] or $MousePos[0] > $WinPos[0] + $WinPos[2] or $MousePos
[1]
> > $WinPos[1] + $WinPos[3] then
> WinClose ("classname=#32768")
> return
> endif
> endif
> EndFunc
>
> Func func_AddToolTipCtrl($ControlID,$ControlMsg)
> _ArrayAdd($a_CtrlIDArray,$ControlID)
> _ArrayAdd($a_CtrlMsgArray,$ControlMsg)
> EndFunc
>
> Func func_Exit()
> Exit
> EndFunc
>
>
> BTW. You can test tooltip window by simple call
>
> if WinExists ("classname=#32768") then .....
>
>
> Valery
>