Phenom Posted October 13, 2010 Share Posted October 13, 2010 I have a lot of information I want to display in a tooltip. I requires several lines. I do not want to have to put all of it in one line, because it's long. If I split the command along multiple lines then it's not recognized. How can this be done? Link to comment Share on other sites More sharing options...
KaFu Posted October 13, 2010 Share Posted October 13, 2010 I use this function in SMF... Func _ToolTip_Wrap_Long_String($s_ToolTip_Org) Local $s_ToolTip_Final Local $s_ToolTip_Work = $s_ToolTip_Org Local $i_ToolTip_Max_StringLen = 120 Local $i_ToolTip_Max_Rows = 8 Local $i_ToolTip_Current_Rows = 0 If StringLen($s_ToolTip_Work) > $i_ToolTip_Max_StringLen Then While StringLen($s_ToolTip_Work) > $i_ToolTip_Max_StringLen $s_ToolTip_Final &= StringLeft($s_ToolTip_Work, $i_ToolTip_Max_StringLen) & @LF $s_ToolTip_Work = StringRight($s_ToolTip_Work, StringLen($s_ToolTip_Work) - $i_ToolTip_Max_StringLen) $i_ToolTip_Current_Rows += 1 If $i_ToolTip_Current_Rows = $i_ToolTip_Max_Rows - 1 Then $s_ToolTip_Work = StringLeft($s_ToolTip_Work, $i_ToolTip_Max_StringLen - 4) & " ..." ExitLoop EndIf WEnd $s_ToolTip_Final &= $s_ToolTip_Work Else $s_ToolTip_Final = $s_ToolTip_Work EndIf StringStripWS($s_ToolTip_Final, 7) ToolTip($s_ToolTip_Final) EndFunc ;==>_ToolTip_Wrap_Long_String OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Phenom Posted October 13, 2010 Author Share Posted October 13, 2010 I use this function in SMF... Func _ToolTip_Wrap_Long_String($s_ToolTip_Org) Local $s_ToolTip_Final Local $s_ToolTip_Work = $s_ToolTip_Org Local $i_ToolTip_Max_StringLen = 120 Local $i_ToolTip_Max_Rows = 8 Local $i_ToolTip_Current_Rows = 0 If StringLen($s_ToolTip_Work) > $i_ToolTip_Max_StringLen Then While StringLen($s_ToolTip_Work) > $i_ToolTip_Max_StringLen $s_ToolTip_Final &= StringLeft($s_ToolTip_Work, $i_ToolTip_Max_StringLen) & @LF $s_ToolTip_Work = StringRight($s_ToolTip_Work, StringLen($s_ToolTip_Work) - $i_ToolTip_Max_StringLen) $i_ToolTip_Current_Rows += 1 If $i_ToolTip_Current_Rows = $i_ToolTip_Max_Rows - 1 Then $s_ToolTip_Work = StringLeft($s_ToolTip_Work, $i_ToolTip_Max_StringLen - 4) & " ..." ExitLoop EndIf WEnd $s_ToolTip_Final &= $s_ToolTip_Work Else $s_ToolTip_Final = $s_ToolTip_Work EndIf StringStripWS($s_ToolTip_Final, 7) ToolTip($s_ToolTip_Final) EndFunc ;==>_ToolTip_Wrap_Long_String How do you call that? Do you just pass the long string? That's the problem. You have to put the long string all in one line. Link to comment Share on other sites More sharing options...
wakillon Posted October 13, 2010 Share Posted October 13, 2010 (edited) It works well with multiple lines ! $_message = 'I have a lot of information ' & @CRLF & _ 'I want to display in a tooltip.' & @CRLF & _ 'I requires several lines.' & @CRLF & _ 'I do not want to have to put all of it in one line, because its long.' & @CRLF & _ 'If I split the command along multiple lines then its not recognized.' & @CRLF & _ 'How can this be done?' Tooltip ( $_message ) Sleep ( 5000 ) Show us how you use tooltip... Edited October 13, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
KaFu Posted October 13, 2010 Share Posted October 13, 2010 (edited) I use it like shown belown. Wraps the tooltip and cuts it to a max length, useful if you don't know the length of the string beforehand ... $string = "aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" $string &= "aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" $string &= "aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" _ToolTip_Wrap_Long_String($string) sleep(10000) Func _ToolTip_Wrap_Long_String($s_ToolTip_Org) Local $s_ToolTip_Final Local $s_ToolTip_Work = $s_ToolTip_Org Local $i_ToolTip_Max_StringLen = 120 Local $i_ToolTip_Max_Rows = 8 Local $i_ToolTip_Current_Rows = 0 If StringLen($s_ToolTip_Work) > $i_ToolTip_Max_StringLen Then While StringLen($s_ToolTip_Work) > $i_ToolTip_Max_StringLen $s_ToolTip_Final &= StringLeft($s_ToolTip_Work, $i_ToolTip_Max_StringLen) & @crlf $s_ToolTip_Work = StringRight($s_ToolTip_Work, StringLen($s_ToolTip_Work) - $i_ToolTip_Max_StringLen) $i_ToolTip_Current_Rows += 1 If $i_ToolTip_Current_Rows = $i_ToolTip_Max_Rows - 1 Then $s_ToolTip_Work = StringLeft($s_ToolTip_Work, $i_ToolTip_Max_StringLen - 4) & " ..." ExitLoop EndIf WEnd $s_ToolTip_Final &= $s_ToolTip_Work Else $s_ToolTip_Final = $s_ToolTip_Work EndIf StringStripWS($s_ToolTip_Final, 7) ToolTip($s_ToolTip_Final) EndFunc ;==>_ToolTip_Wrap_Long_String Edited October 13, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Phenom Posted October 13, 2010 Author Share Posted October 13, 2010 It works well with multiple lines ! $_message = 'I have a lot of information ' & @CRLF & _ 'I want to display in a tooltip.' & @CRLF & _ 'I requires several lines.' & @CRLF & _ 'I do not want to have to put all of it in one line, because its long.' & @CRLF & _ 'If I split the command along multiple lines then its not recognized.' & @CRLF & _ 'How can this be done?' Tooltip ( $_message ) Sleep ( 5000 ) Show us how you use tooltip... I just put the string all in one line. I notice that you are using _ to split it into multiple lines. That solves the problem, thanks. Link to comment Share on other sites More sharing options...
wakillon Posted October 13, 2010 Share Posted October 13, 2010 @KaFuLooks good !I thought he was talking about the number of lines and not their lengths... AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
wakillon Posted October 13, 2010 Share Posted October 13, 2010 I just put the string all in one line. I notice that you are using _ to split it into multiple lines. That solves the problem, thanks.I use _ just for display the script more easily, not for split text ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts 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