mohammadezazi Posted July 17, 2013 Share Posted July 17, 2013 (edited) Hi and thanks to all Is it possible to align or justificate tooltip texts to Right side of it ? There is no parameter in its parameters list for this issue. ToolTip ( "text" [, x [, y [, "title" [, icon [, options]]]]] ) And the Options are: optional] Sets different options for how the tooltip will be displayed (Can be added together): 1 = Display as Balloon Tip Requires IE5+ 2 = Center the tip at the x,y coordinates instead of using them for the upper left corner. 4 = Force the tooltip to always be visible confining it to monitor borders if necessary. If multiple monitors are used, then the tooltip will "snap-to" the nearest monitor. Edited July 17, 2013 by mohammadezazi Link to comment Share on other sites More sharing options...
BrewManNH Posted July 17, 2013 Share Posted July 17, 2013 I'd try a combination of Melba23's StringSize function and StringFormat with spaces in front of the text and see if that accomplishes what you need. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
mohammadezazi Posted July 17, 2013 Author Share Posted July 17, 2013 Thanks for your reply. Ill check it. Link to comment Share on other sites More sharing options...
Malkey Posted July 18, 2013 Share Posted July 18, 2013 Here is a close attempt to format multiply lines of text in order to right justify the lines in a tooltip. expandcollapse popup;#include <Array.au3> ToolTip(_TTipRightJustify("This is a tooltip" & @CRLF & "right" & @LF & "6" & @LF & "THIS IS A TOOLTIP" & @LF & "." & @LF & "Last line."), 50, 50) MsgBox(0, "The End", 'Press "Ok" to finish.') ; Uses GUICtrlCreateLabel function with default optional parameter autofit text's width. Func _TTipRightJustify($sString) Local $sFormatStr = "", $sVars = "", $iMaxLen = 0, $iMaxIndex = 0, $sPos, $sPosT, $Lab Local $aArr = StringSplit($sString, @LF, 2) ;_ArrayDisplay($aArr) Local $hGui = GUICreate("My GUI") ; -- Get longest line in pixels. -- For $i = 0 To UBound($aArr) - 1 $Lab = GUICtrlCreateLabel($aArr[$i], -1, -1) $sPos = ControlGetPos("My GUI", "", $Lab) If $sPos[2] > $iMaxLen Then $iMaxLen = $sPos[2] $iMaxIndex = $i EndIf Next ; Keep adding spaces to the beginning of each line until that line is equal to or greater than the longest line in pixels. For $i = 0 To UBound($aArr) - 1 For $j = 1 To StringLen($aArr[$iMaxIndex]) * 2 $Lab = GUICtrlCreateLabel(StringFormat("%" & $j & "s", $aArr[$i]), -1, -1) $sPosT = ControlGetPos("My GUI", "", $Lab) ; $sPosT[2] is length of line in pixels. If $sPosT[2] >= $iMaxLen Then $sVars &= '"' & $aArr[$i] & '",' If $i = $iMaxIndex Then $sFormatStr &= '%' & StringLen($aArr[$iMaxIndex]) & 's\n' ElseIf StringLen($aArr[$i]) = 1 Then $sFormatStr &= '%' & $j & 's\n' ; No adjustment to align right edge of lines. Else $sFormatStr &= '%' & ($j - 1) & 's\n' ; "-1" for slight adjustment to align right edge of lines. EndIf ExitLoop EndIf Next Next $sVars = StringTrimRight($sVars, 1) ; Trim unwanted trailing coma. $sFormatStr = StringTrimRight($sFormatStr, 2); Trim unwanted trailing "\n" GUIDelete($hGui) Return Execute('StringFormat("' & $sFormatStr & '", ' & $sVars & ')') EndFunc ;==>_TTipRightJustify Link to comment Share on other sites More sharing options...
mohammadezazi Posted July 18, 2013 Author Share Posted July 18, 2013 Oh! Very nice and useful code. Thank you Malkey for your help and attention. 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