Jump to content

_GUICtrlIpAddress VS GUICtrlSetTip


dongaman
 Share

Recommended Posts

Welcome to the forums :evil:

Thats becouse its not a standard autoit control. Try _GUIToolTip_Create, I haven't yet, but I think that it will work in a similar way. There seems to be a complete lack of examples in the helpfile for the _GUITooltip_* functions, which is rather unusual, so sorry for that.

Thanx ;)

So,is below methods right?

_GUIToolTip_Create

_GUIToolTip_Activate

_GUIToolTip_Destroy

Link to comment
Share on other sites

After search all the forums, I can not find the way that make GuiToolTip worked?

#include <GuiConstantsEx.au3>
#include <GuiIPAddress.au3>
#Include <GuiToolTip.au3>

$hgui = GUICreate("IP Address Example", 300, 200)

$hIPAddress = _GUICtrlIpAddress_Create($hgui, 10, 10)
;WinSetState($hIPAddress, "", @SW_DISABLE)
_GUICtrlIpAddress_Set($hIPAddress, "24.168.2.128")

$hTool = _GUIToolTip_Create(GUICtrlGetHandle($hIPAddress))
MsgBox(0,"",_GUIToolTip_AddTool($hTool,$hgui, "sadfasdddddddddd"))

_GUIToolTip_Activate($hTool,True)
MsgBox(0,"",_GUIToolTip_GetText($hgui,GUICtrlGetHandle($hIPAddress), 0))
GUISetState(@SW_SHOW)

Do

Until GUIGetMsg() = $GUI_EVENT_CLOSE
Link to comment
Share on other sites

OOOOOOOOOOOh my god.Your answer is 'no answer' ;)

Hey! I worked for quite a while getting this to the stage that it now returns true. Doesn't work though!:evil:

#include <WinApi.au3>
#include <SendMessage.au3>
#include <TooltipConstants.au3>
#include <WindowsConstants.au3>

Global Const $TOOLTIPS_CLASS = "tooltips_class32"

Global Const $tagTOOLINFO = "uint cbSize;uint uFlags;hwnd hWnd;uint_ptr uID;int Left;int Top;int Right;int Bottom;handle hInst;ptr lpszText;lparam Param;ptr lpReserved"

Global $g_hInst

CreateGUI()

Func CreateGUI()
    Local $hGUI = GUICreate("Testing tooltip")
    Local $hCtrl = GUICtrlCreateLabel("This is the test!", 0, 0, 200, 200)

    If CreateToolTip($hCtrl, $hGUI, "This is a test") Then
        MsgBox (0, "Success!", "It worked... apparently.")
    Else
        MsgBox (16, "Failure!", "It failed: " & @error & ".")
    EndIf

    GUISetState()

    While GUIGetMsg() <> -3
        ;;;
    WEnd
EndFunc   ;==>CreateGUI

Func CreateToolTip($toolID, $hDlg, $pText)
    ; toolID:  the resource ID of the control.
    ; hDlg:    the handle of the dialog box.
    ; pText:   the text that appears in the tooltip.
    ; g_hInst: the global instance handle.

    If (Not $toolID) Or (Not $hDlg) Or (Not $pText) Then Return False

    ; Get the window of the tool.
    Local $hwndTool = _WinAPI_GetDlgItem($hDlg, $toolID)

    ; Create the tooltip.
    Local $hwndTip = _WinAPI_CreateWindowEx(0, $TOOLTIPS_CLASS, 0, _
                                            BitOR($WS_POPUP, $TTS_ALWAYSTIP, $TTS_BALLOON), _
                                            0, 0, _
                                            200, 30, _
                                            $hDlg, 0, _
                                            $g_hInst, 0)

    If (Not $hwndTool) Or (Not $hwndTip) Then Return False

    Local $tToolInfo = DllStructCreate($tagTOOLINFO)

    ; Associate the tooltip with the tool.

    DllStructSetData($tToolInfo, "cbSize", DllStructGetSize($tToolInfo))
    DllStructSetData($tToolInfo, "hWnd", $hDlg)
    DllStructSetData($tToolInfo, "uFlags", BitOR($TTF_IDISHWND, $TTF_SUBCLASS))
    DllStructSetData($tToolInfo, "uId", $hwndTool)
    DllStructSetData($tToolInfo, "lpszText", $pText)
    _SendMessage($hwndTip, $TTM_ADDTOOL, 0, $tToolInfo)

    Return True
EndFunc   ;==>CreateToolTip

based on this code:

BOOL CreateToolTip(int toolID, HWND hDlg, WCHAR* pText)
{
    // toolID:  the resource ID of the control.
    // hDlg:    the handle of the dialog box.
    // pText:   the text that appears in the tooltip.
    // g_hInst: the global instance handle.
    
    if (!toolID || !hDlg || !pText)
    {
        return FALSE;
    }
    // Get the window of the tool.
    HWND hwndTool = GetDlgItem(hDlg, toolID);
    
    // Create the tooltip.
    HWND hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL,
                              WS_POPUP |TTS_ALWAYSTIP | TTS_BALLOON,
                              CW_USEDEFAULT, CW_USEDEFAULT,
                              CW_USEDEFAULT, CW_USEDEFAULT,
                              hDlg, NULL, 
                              g_hInst, NULL);
                              
   if (!hwndTool || !hwndTip)
   {
       return FALSE;
   }                              
                              
    // Associate the tooltip with the tool.
    TOOLINFO toolInfo = { 0 };
    toolInfo.cbSize = sizeof(toolInfo);
    toolInfo.hwnd = hDlg;
    toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
    toolInfo.uId = (UINT_PTR)hwndTool;
    toolInfo.lpszText = pText;
    SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);

    return TRUE;
}

I learnt a fair bit... But how to make those tooltips work is not one of them.

Link to comment
Share on other sites

OOOOOOOOOOOh my god.Your answer is 'no answer' ;)

Following advice from Geosoft to James3mg in another thread today, try using ToolTip instead.

#include <GuiConstantsEx.au3>
#include <GuiIPAddress.au3>

Global $Struct = DllStructCreate($tagPoint)
$hgui = GUICreate("IP Address Example", 300, 200)

$hIPAddress = _GUICtrlIpAddress_Create($hgui, 10, 10)
$wh = ControlGetPos($hgui, "", $hIPAddress)
_GUICtrlIpAddress_Set($hIPAddress, "24.168.2.128")

GUISetState(@SW_SHOW)
Opt("MouseCoordMode", 2)
Do
    $mp = MouseGetPos()
    If $mp[0] < $wh[0] Or $mp[0] > $wh[2] Or $mp[1] < $wh[1] Or $mp[1] > $wh[3]+8 Then
    ToolTip("")
    Else
    $savemm = Opt("MouseCoordMode", 1)
    $mp = MouseGetPos()
    ToolTip("blah Blah", $mp[0], $mp[1] - 20)
    Opt("MouseCoordMode", $savemm)
    EndIf


Until GUIGetMsg() = $GUI_EVENT_CLOSE
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...