Function Reference


_GUIToolTip_NewToolRect

Sets a new bounding rectangle for a tool

#include <GuiToolTip.au3>
_GUIToolTip_NewToolRect ( $hTool, $hWnd, $iID, $iLeft, $iTop, $iRight, $iBottom )

Parameters

$hTool Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$hWnd Handle of the window that contains the tool, or 0
$iID Identifier of the tool, or Window handle of the control the tool is to be assigned to
$iLeft X coordinate of the upper left corner of the rectangle
$iTop Y coordinate of the upper left corner of the rectangle
$iRight X coordinate of the lower right corner of the rectangle
$iBottom Y coordinate of the lower right corner of the rectangle

Return Value

See remark.

Remarks

If $hWnd referenced control is not in the same process and both processes run in different AutoIt mode (@AutoItVersion), the @error is set to 6.

Related

_GUIToolTip_AdjustRect

Example

Example 1

#include "Extras\HelpFileInternals.au3"

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>
#include <StructureConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("ToolTip New ToolRect v(" & @AutoItVersion & ")", 450, 300, 100, 100)

    ; create a tooltip control using default settings
    Local $hToolTip = _GUIToolTip_Create(0)
    _MemoSetHandleInProcess($hToolTip)

    Local $idButton = GUICtrlCreateButton("Button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)

;~  $hGUI = 0 ; is OK
    _GUIToolTip_AddTool($hToolTip, $hGUI, "This is the ToolTip text", $hButton)

    GUISetState(@SW_SHOW)

    ; Show the tooltip associated with the button
    Opt("MouseCoordMode", 2)
    MouseMove(60, 42, 0)
    Sleep(250)

    ; Retrieve the text of the tool
    Local $tRect = DllStructCreate($tagRECT)
    Local $aRect[4] = [100, 100, 240, 140]
    DllStructSetData($tRect, "Left", $aRect[0])
    DllStructSetData($tRect, "Top", $aRect[1])
    DllStructSetData($tRect, "Right", $aRect[2])
    DllStructSetData($tRect, "Bottom", $aRect[3])
    _GUIToolTip_NewToolRect($hToolTip, $hGUI, $hButton, $aRect[0], $aRect[1], $aRect[2], $aRect[3])

    Local $aTool = _GUIToolTip_GetToolInfo($hToolTip, $hGUI, $hButton)
    _MemoMsgBox($MB_SYSTEMMODAL, 'New ToolRect = ', _
            "Flags: " & @TAB & _GUIToolTip_BitsToTTF($aTool[0]) & @CRLF & _
            "HWnd: " & @TAB & "0x" & Hex($aTool[1]) & @CRLF & _
            "ID: " & @TAB & "0x" & Hex($aTool[2]) & @CRLF & _
            "Left X:" & @TAB & $aTool[3] & @CRLF & _
            "Left Y:" & @TAB & $aTool[4] & @CRLF & _
            "Right X:" & @TAB & $aTool[5] & @CRLF & _
            "Right Y:" & @TAB & $aTool[6] & @CRLF & _
            "Instance:" & @TAB & $aTool[7] & @CRLF & _
            "Text:" & @TAB & $aTool[8] & @CRLF & _
            "lParam:" & @TAB & $aTool[9])

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

    ; Destroy the tooltip control
    _MemoResetHandleInProcess($hToolTip)
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example

Example 2 : ToolTip New ToolRect to an External process

#include "Extras\HelpFileInternals.au3"

#include <GUIToolTip.au3>
#include <StructureConstants.au3>

Example()

Func Example()
    Local $sFromTo
    Local $hWin = _MemoRunAU3OutProcess($sFromTo, True) ; OK same mode, KO if different mode
    Local $hButton = _MemoCreateOutProcess($hWin, "Button", 1, $sFromTo)

    Local $hToolTip = _MemoGetHandleInProcess()

    Local $tRect = DllStructCreate($tagRECT)
    Local $aRect[4] = [150, 150, 340, 140]
    DllStructSetData($tRect, "Left", $aRect[0])
    DllStructSetData($tRect, "Top", $aRect[1])
    DllStructSetData($tRect, "Right", $aRect[2])
    DllStructSetData($tRect, "Bottom", $aRect[3])

    _GUIToolTip_NewToolRect($hToolTip, $hWin, $hButton, $aRect[0], $aRect[1], $aRect[2], $aRect[3])
    If @error Then
        _MemoMsgBox($MB_ICONERROR, "Info" & $sFromTo, "_GUIToolTip_NewToolRect()" & " @error = " & @error & @CRLF & _
                @TAB & "cannot be accessed from an external process" & @CRLF & _
                @TAB & "running in different mode")
    Else
        ; only working if both processes are running in "same mode"
        Local $aTool = _GUIToolTip_GetToolInfo($hToolTip, $hWin, $hButton)
        _MemoWrite("<<< Tooltip info" & $sFromTo & @CRLF & _
                "Flags: " & @TAB & _GUIToolTip_BitsToTTF($aTool[0]) & @CRLF & _
                "HWnd: " & @TAB & "0x" & Hex($aTool[1]) & @CRLF & _
                "ID: " & @TAB & "0x" & Hex($aTool[2]) & @CRLF & _
                "Left X:" & @TAB & @TAB & $aTool[3] & @CRLF & _
                "Left Y:" & @TAB & @TAB & $aTool[4] & @CRLF & _
                "Right X:" & @TAB & $aTool[5] & @CRLF & _
                "Right Y:" & @TAB & $aTool[6] & @CRLF & _
                "Instance:" & @TAB & $aTool[7] & @CRLF & _
                "Text:" & @TAB & $aTool[8] & @CRLF & _
                "lParam:" & @TAB & $aTool[9])
    EndIf

    _MemoMsgBoxStatus("", Default, $hWin) ; no more action, wait GUI for closing, close also OutProcess GUI

EndFunc   ;==>Example