Jump to content

WM_HELP & Tooltip


Recommended Posts

How I can remove the tooltip after its activation through WM_HELP message.

Thanks.

#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

$Form = GUICreate("My GUI", 400, 400, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $DS_CONTEXTHELP), $WS_EX_CONTEXTHELP)

$Button = GUICtrlCreateButton("Exit", 165, 360, 70, 23)
GUIRegisterMsg($WM_HELP, '_WM_HELP')

GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $Button, $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _WM_HELP($hWnd, $msgID, $wParam, $lParam)

    Local $tPOINT = _WinAPI_GetMousePos()
    Local $hHandle = _WinAPI_WindowFromPoint($tPOINT)
    Local $ID = _WinAPI_GetDlgCtrlID($hHandle)

    If _IsPressed(70) Then
        Switch $ID
            Case $Button
                Run('hh.exe ' & RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir') & '\AutoIt3.chm')
        EndSwitch   
    Else
        ToolTip('This is a tooltip', DllStructGetData($tPOINT, 1), DllStructGetData($tPOINT, 2), '', 0, 1)
    EndIf
EndFunc   ;==>_WM_HELP
Link to comment
Share on other sites

ToolTip("")

An empty string clears a displaying tooltip

:)

I know it, but how to catch those moments when I need to remove the tooltip? I want to make sure how it works in Windows. For example, the standard Mouse Properties Dlg.

Link to comment
Share on other sites

Remove it with a Timer

#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Timers.au3>

$Form = GUICreate("My GUI", 400, 400, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $DS_CONTEXTHELP), $WS_EX_CONTEXTHELP)

$Button = GUICtrlCreateButton("Exit", 165, 360, 70, 23)
GUIRegisterMsg($WM_HELP, '_WM_HELP')

Global $bTooltipActive = False
Global $iTooltipTime
_Timer_SetTimer($Form, 250, "_Remove_WM_HELP_Tooltip")

GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $Button, $GUI_EVENT_CLOSE
            _Timer_KillAllTimers($Form)
            Exit
    EndSwitch
WEnd

Func _WM_HELP($hWnd, $msgID, $wParam, $lParam)
    Local $tPOINT = _WinAPI_GetMousePos()
    Local $hHandle = _WinAPI_WindowFromPoint($tPOINT)
    Local $ID = _WinAPI_GetDlgCtrlID($hHandle)

    If _IsPressed(70) Then
        Switch $ID
            Case $Button
                Run('hh.exe ' & RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir') & '\AutoIt3.chm')
        EndSwitch
    Else
        $bTooltipActive = True
        $iTooltipTime = TimerInit()
        ToolTip('This is a tooltip', DllStructGetData($tPOINT, 1), DllStructGetData($tPOINT, 2), '', 0, 1)
    EndIf
EndFunc   ;==>_WM_HELP

Func _Remove_WM_HELP_Tooltip($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime
    if $bTooltipActive = True Then
        if TimerDiff($iTooltipTime) > 1000 Then
            ToolTip('')
            $bTooltipActive = False
        endif
    endif
EndFunc   ;==>_Remove_WM_HELP_Tooltip
Link to comment
Share on other sites

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