TimRude Posted February 17 Share Posted February 17 (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 + ($aPos / 2) Local $iY = $aPos + ($aPos / 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 by TimRude Link to comment Share on other sites More sharing options...
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
Already have an account? Sign in here.Sign In Now