TimRude Posted February 17, 2023 Share Posted February 17, 2023 (edited) I'm seeing odd positioning behavior with the ToolTip command when using the $TIP_FORCEVISIBLE flag. Here's sample code to create a GUI which, when right-clicked, will display a balloon tooltip for 2.5 seconds in the center of the GUI. #NoTrayIcon #include <APIConstants.au3> Example() Func Example() Local $hGUI = GUICreate("Sample GUI", 400, 300) Local $idText = GUICtrlCreateLabel("Right-click window to see tooltip", 20, 125, 360, Default, $SS_CENTER) GUICtrlSetFont(-1, 12) GUISetState(@SW_SHOW) Local $hTimer = 0 While 1 Local $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ; ESC pressed - close the dialog ExitLoop Case $GUI_EVENT_SECONDARYUP ; right-click on dialog to display tooltip Local $aPos = WinGetPos($hGUI) Local $iX = $aPos[0] + ($aPos[2] / 2) Local $iY = $aPos[1] + ($aPos[3] / 2) ToolTip("Here's your tooltip!", $iX, $iY, Default, Default, $TIP_BALLOON + $TIP_CENTER + $TIP_FORCEVISIBLE) $hTimer = TimerInit() ; start the clock running on the tooltip EndSwitch If $hTimer <> 0 Then If TimerDiff($hTimer) >= 2500 Then ; 2.5 seconds have elapsed, hide the tooltip ToolTip("") $hTimer = 0 EndIf EndIf WEnd If $hTimer <> 0 Then ToolTip("") GUIDelete($hGUI) EndFunc ;==>Example Now move the GUI over to the right so most of it is off the edge of the screen and then right-click it again to display the tooltip. I would expect the tooltip to be displayed as close to the right edge of the screen as possible without going off of it. However, there's a gap of about 60 pixels or so between the tooltip and the right-edge. Now move the GUI over to the left so most of it is off the edge of the screen and then right-click it again to display the tooltip. I would expect the tooltip to be fully displayed as close to the left edge of the screen as possible without going off of it. However, the tooltip is allowed to be displayed partially off-screen. In the ToolTip help docs, it says: "$TIP_FORCEVISIBLE (4) = Force the tooltip to always be visible confining it to monitor borders if necessary." It doesn't appear to be doing this quite right. If I remove the $TIP_CENTER flag, it then positions the tooltip properly up against each edge of the screen. So there's evidently something about the combination of $TIP_CENTER and $TIP_FORCEVISIBLE that's throwing off the positioning calculations Edited February 17, 2023 by TimRude Link to comment Share on other sites More sharing options...
TimRude Posted February 17, 2023 Author Share Posted February 17, 2023 A bit of additional testing finds that the gap on the right side is 1/2 the width of the tooltip. If I make the tooltip text longer, the gap becomes longer. And likewise the portion of the tooltip that displays off the left side of the screen is always no more than the left-half of the tooltip. Link to comment Share on other sites More sharing options...
TimRude Posted February 18, 2023 Author Share Posted February 18, 2023 (edited) Submitted to Bug Tracker. https://www.autoitscript.com/trac/autoit/ticket/3941 Edited February 18, 2023 by TimRude Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now