Sign in to follow this  
Followers 0
Tacomas

Is there a way to test if an Edit control already has a tooltip?

5 posts in this topic

#1 ·  Posted (edited)

I'm currently working on a GUI that has 2 Edits for entering a start and an end address.

 

$txt_StartAddr = GUICtrlCreateInput('', 110, 346, 50, 20, $ES_RIGHT + $ES_NUMBER)
$txt_EndAddr   = GUICtrlCreateInput('', 110, 371, 50, 20, $ES_RIGHT + $ES_NUMBER)
When these 2 inputs are created it's only possible to enter numbers, otherwise a balloon tip is displayed with a hint that only numbers can be used.

Now I want to test if the end address is larger than the start address and if not, show a similar balloon tip but it fails, i.e. no balloon tip is shown. My guess is that this is because _GUICtrlEdit_ShowBalloonTip() is called repeatedly (I run this check in the main loop).

 

If $iFocussedCtrl = $txt_StartAddr Then
        If GUICtrlRead($txt_StartAddr) > GUICtrlRead($txt_EndAddr) Then 
            _GUICtrlEdit_ShowBalloonTip($txt_StartAddr, 'Error', 'Start address must be smaller than End address!', $TTI_ERROR)
        EndIf
    EndIf
    If $iFocussedCtrl = $txt_EndAddr Then
        If GUICtrlRead($txt_EndAddr) < GUICtrlRead($txt_StartAddr) Then
            _GUICtrlEdit_ShowBalloonTip($txt_EndAddr, 'Error', 'End address must be larger than End address!', $TTI_ERROR)
        EndIf
    EndIf
Is there a way to check if an Edit control already has a tooltip? Or does anyone know how this could be solved in a different way? Edited by Tacomas

Share this post


Link to post
Share on other sites



hi Tacomas

I do not know how the $iFocussedCtrl is generated, anyway I think more issues overlaps in  your check loop:

when you use the _GUICtrlEdit_ShowBalloonTip()  it seems that it also sets the focus to its input control, triggering a "nested" loop that turns on continuously  the balloontip, resulting in a nearly invisible ballon effect.

try to use TrayTip ( "title", "text", 2) instead of _GUICtrlEdit_ShowBalloonTip as a "first step alternative"....

bye


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Oups I knew I forgot something, sorry! :)

 

The value of $iFocussedCtrl is returned by this function:

 

$iFocussedCtrl = _GuiUtils_GetFocussedControl($hWnd)

Func _GuiUtils_GetFocussedControl($wndTitle)
    Local $sClassNameNN = ControlGetFocus($wndTitle)
    If @error Then Return SetError(1,0,-1)
    Local $hCtrl = ControlGetHandle($wndTitle, '', $sClassNameNN)
    If @error Then Return SetError(2,0,-1)
    Local $callRes = DllCall('user32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hCtrl)
    If @error Then Return SetError(3,0,-1)
    Return $callRes[0]
EndFunc ;==>_GuiUtils_GetFocussedControl
So basically it's the controlID of the control that currently has the focus in the given GUI.

 

I also thought about the TrayTip or a MsgBox but then I would have 2 different ways in which warnings/errors are presented to the user and from a usability point of view this is a bad thing so I try to avoid it. I share your opinion that when _GUICtrlEdit_ShowBalloonTip() is called repeatedly then it constantly overwrites the previous balloon tip which results in having no visible balloon tip.

Since AutoIt is very flexible I just can't believe that it shouldn't be possible to do what I try to achieve. :)

Share this post


Link to post
Share on other sites

Hi Tacomas,

well, then you might try this way:

1) initializes a timer at the beginning of your program by adding this line:

$Tipdelay = TimerInit()

2) Add this subroutine to the bottom of your program to insert a delay in the display of BalloonTips:

Func Tip($v1,$v2,$v3,$v4)
    if int(TimerDiff($Tipdelay)/1000) > 3 Then
        _GUICtrlEdit_ShowBalloonTip($v1,$v2,$v3,$v4)
        $Tipdelay = TimerInit()
    endif
EndFunc

3) and call it instead of _GUICtrlEdit_ShowBalloonTip () in this way:

; instead of this lines
    ; _GUICtrlEdit_ShowBalloonTip($txt_StartAddr, 'Error', 'Start address must be smaller than End address!', $TTI_ERROR)
    ; use the following alternative:
        Tip($txt_EndAddr, 'Error', 'End address must be larger than End address!', $TTI_ERROR)

the overall effect of displaying BalloonTip should be acceptable now.

bye


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Thank you Pincopanco! This works quite well. :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0