Jump to content

ToolTip position issue


Recommended Posts

Hi everybody :)
I got an issue with the ToolTip command, let me explain with 4 simple examples :

#include <AutoItConstants.au3>

ToolTip("This is tooltip 1", 0, 0)
Sleep(3000)

438904626_Tooltip1.png.2356ab1c5c9d4bdc988fd9568bf7c29d.png

Example 1 above is correct : tooltip 1 shown in the pic got its upper left corner at 0, 0

*************************************************************************

#include <AutoItConstants.au3>

ToolTip("This is tooltip 2", 45, 10, "", $TIP_NOICON, $TIP_CENTER)
Sleep(3000)

1295141545_Tooltip2.png.2d2853f180e8e16cf69ffd07c9beafc8.png

Example 2 above is correct : tooltip 2 shown in the pic is centered at coords 45, 10

*************************************************************************

#include <AutoItConstants.au3>

ToolTip("This is tooltip 1", 0, 0)
Sleep(3000)

ToolTip("")

ToolTip("This is tooltip 2", 45, 10, "", $TIP_NOICON, $TIP_CENTER)
Sleep(3000)

1383829716_Tooltip12.png.ba758326f76cfe630dd96d94fab3ba9b.png

Example "1+2" above is incorrect : tooltip 2 shown in the pic is no more centered at coords 45, 10 as it should be. In fact, its upper left corner is placed at 45, 10

*************************************************************************

#include <AutoItConstants.au3>

ToolTip("This is tooltip 2", 45, 10, "", $TIP_NOICON, $TIP_CENTER)
Sleep(3000)

ToolTip("")

ToolTip("This is tooltip 1", 0, 0)
Sleep(3000)

678402391_Tooltip21.png.aaf086b45f1732efc4c13934a8addcd0.png

Example "2+1" above is incorrect : tooltip 1 shown in the pic got no more its upper left corner at 0, 0 as it should be. In fact, its centered at 0, 0 (that's why half of it is missing horizontally & vertically)

So it seems that when there are 2 different kind of tooltips in the same script (some centered on coords, others not), then the 1st Tooltip options rule (as in examples "1+2" and "2+1") no matter the options found in the following tooltips.

As I would like to use these 2 kind of tooltips in the same script, it would be great if any of you faced this problem and found a solution.
Thanks :)

Link to comment
Share on other sites

Looks like the new instance of the tooltip uses/adds some of the settings from the previous instance.

I'v played a bit with the scripts and this is the solution:

#include <AutoItConstants.au3>

ToolTip("This is tooltip 2", 45, 10, "", $TIP_NOICON, $TIP_CENTER)
Sleep(3000)

ToolTip("",0,0,"",0,$TIP_BALLOON)


ToolTip("This is tooltip 1", 1, 2)
Sleep(3000)

Simply, reset/clear the tooltip as ToolTip("",0,0,"",0,$TIP_BALLOON)

Edited by Dan_555

Some of my script sourcecode

Link to comment
Share on other sites

@Dan_555 : fantastic, now it works like a charm !

Here is how it displays now in my script, because sometimes I need to see what's under the centered tooltip, before cropping.

1413676821_2differenttooltips.jpg.5aa31057a426783f48c5cb924cf5a761.jpg

In fact I do many operations using the mouse :
* Next image in the list with a single left click on the image
* Resizing using mouse wheel => Func WM_MOUSEWHEEL()
* Cropping with left click pressed > 0.3s
* Undo last crop with right click > 0.3s
* Save result with right click
* Not counting the whole bunch of keys used as Accelerators to navigate within the list of pics (inspired by ACDSee's keys used while browsing a list of pics)

$idDummy_Wheel = GUICtrlCreateDummy() ; variable globale : WM_MOUSEWHEEL() => $idDummy_Wheel
$idDummy_Esc = GUICtrlCreateDummy()   ; variable globale : HotKeySet => _Wanna_Quit() => $idDummy_Esc

Local $idDummy_Enter = GUICtrlCreateDummy(), _
    $idDummy_Right = GUICtrlCreateDummy(), $idDummy_Left = GUICtrlCreateDummy(), _
    $idDummy_Home = GUICtrlCreateDummy(), $idDummy_End = GUICtrlCreateDummy(), _
    $idDummy_Up = GUICtrlCreateDummy(), $idDummy_Down = GUICtrlCreateDummy()

Local $aAccelKeys[11][2] = [["{ENTER}", $idDummy_Enter], _
    ["{RIGHT}", $idDummy_Right], ["{SPACE}", $idDummy_Right], _
    ["{LEFT}", $idDummy_Left], ["{BACKSPACE}", $idDummy_Left], _
    ["{HOME}", $idDummy_Home], ["{END}", $idDummy_End], _
    ["{UP}", $idDummy_Up], ["{NUMPADADD}", $idDummy_Up], _
    ["{DOWN}", $idDummy_Down], ["{NUMPADSUB}", $idDummy_Down]]

GUISetAccelerators($aAccelKeys)
...

Thanks again Dan :thumbsup:

Link to comment
Share on other sites

  • 3 weeks later...
On 8/13/2020 at 7:34 PM, Dan_555 said:

Looks like the new instance of the tooltip uses/adds some of the settings from the previous instance.

I got a similar (worse) problem with ToolTip, which makes a script completely freeze. Even an Esc HotKey to end the script doesn't respond. The only way to stop the script is to use the Task manager to kill AutoIt3.exe

Our discussion above indicated that the problem happened when several Tooltips didn't get the same parameters.
But now I find a "complicated" case where the issue appears with only one tooltip in the script, for example, a tooltip placed in a function which will be called several times during the script :

Func Show_Tooltip()
    ToolTip("text here", @DesktopWidth / 2, (@DesktopHeight - $iY_resized) / 2 + 9, "", 0, 2)
    ; + 9 (good position), 0 = no icon, 2 = center tip at x,y
EndFunc

1st time the function is called : no problem.
2nd time the function is called : the script freezes under certain conditions.

To solve the issue in all cases (no more freeze) then the function needs to be called like this :

Func Show_Tooltip()
    ToolTip("", 0, 0, "", 0, $TIP_BALLOON) ; Dan_555's patch as ToolTip("") isn't enough
    
    ToolTip("text here", @DesktopWidth / 2, (@DesktopHeight - $iY_resized) / 2 + 9, "", 0, 2)    
    ; + 9 (good position), 0 = no icon, 2 = center tip at x,y
EndFunc

This tip could be helpful in case your script froze and you don't know why, in case you got a tooltip in it.

For those of you who are really interested in this issue, here are some infos about the "complicated" case where it happens to me. It involves all of the following :
* a parent window $hGUI_Background created with $WS_EX_COMPOSITED extended style (..., $WS_POPUP, $WS_EX_COMPOSITED). Please note that this parent window covers exactly all desktop (width = @DesktopWidth, height = @DesktopHeight)
* a child window $hGUI_Preview created with $WS_CHILD style, parent $hGUI_Background (..., $WS_CHILD, -1, $hGUI_Background)
* a control image $idPic inside the child window, coords 0, 0 and control size = same size as the child window
* GUICtrlSetResizing($idPic, $GUI_DOCKAUTO) so the control image "resizes and repositions according to new window size", great !
* Mouse wheel calls Func WM_MOUSEWHEEL() to zoom + or - the child window (i.e the image) => WinMove($hGUI_Preview, ...)
* a tooltip displayed at the top of the child window, each time the image is resized (issue would occur wherever the tooltip is displayed)
* freeze arrives as soon as the zoomed image width reaches @DesktopWidth

Interesting : as soon as I remove the extended style $WS_EX_COMPOSITED, then there is no freeze at all, even without Dan_555's patch !
But as I added $WS_EX_COMPOSITED to remove all flickering while zooming (and it really works fine), then I'll never remove $WS_EX_COMPOSITED any more.

Here is something else I discovered 5 min ago : if the parent GUI didn't cover the whole desktop, then things would have gone much better.
For example let's create the parent GUI with Width = @DesktopWidth and Height = @DesktopHeight - 100 (tested)
Now we can display the tooltip in a part of the screen outside the parent GUI and there's no freezing at all... even without Dan_555's patch !

So it seems that there is an issue during the redraw, when the parent window got a $WS_EX_COMPOSITED extended style and a tooltip is already present "covering" the parent window.
Gee... it wasn't easy to debug. Thanks to Dan_555 for having found a solution and to Jpm who sent the fix to Jon :)

Link to comment
Share on other sites

Demonstrative pics :

* Vertical coord of parent window : 50
* Black background of parent window
* Left side of pic : tooltip centered at 41 vertical : its bottom black border (1 pixel) is displayed outside of the parent window : no freeze
* Right side of pic : tooltip centered at 42 vertical : its bottom black border (1 pixel) overlaps the parent window with 1 pixel : freeze

2138771653_Tootipnofreeze-freeze.png.799be6729243eaf19e301de378bfbb53.png

955274169_Tootipnofreeze-freeze(zoomed).png.28519a01c5991224e6c7ea18104a811e.png

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