PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Multiline tooltip  (Read 151 times)

SeaVipe

  • Senior Member
  • ***
  • Posts: 407
  • Windows 10
Multiline tooltip
« on: December 26, 2021, 09:38:42 PM »

Happy Boxing Day!
Does anyone have experience with Multiline tooltip text?
Thanks.
Logged
Clive Richey
You're Either Part Of The Solution, Or You're The Problem.
#StaySafe, Always  Keep A Safe #SocialDistance, #WashYourHands Often and please, #StayHome!

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9411
  • Windows 10
    • PlanetSquires Software
Re: Multiline tooltip
« Reply #1 on: December 27, 2021, 12:31:18 AM »

Hi Clive,

I just tried some tests using WinFBE which uses Jose's tooltip Afx routines to create the tooltip and assign text. I have not yet found a way for the tooltip to interpret a \n linefeed within the string that should break the text into separate lines.

I am off to bed but hopefully tomorrow I will get an inspiration for something that I am overlooking.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

SeaVipe

  • Senior Member
  • ***
  • Posts: 407
  • Windows 10
Re: Multiline tooltip
« Reply #2 on: December 27, 2021, 12:40:42 AM »

Thank you, Paul!
Logged
Clive Richey
You're Either Part Of The Solution, Or You're The Problem.
#StaySafe, Always  Keep A Safe #SocialDistance, #WashYourHands Often and please, #StayHome!

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9411
  • Windows 10
    • PlanetSquires Software
Re: Multiline tooltip
« Reply #3 on: December 27, 2021, 08:31:50 AM »

Looks like you need to set the tooltip max tip with via a sendmessage call otherwise the tooltip will not properly interpret the embedded linefeeds. I used 200 in the example below. I will see how to integrate this into WinFBE's generated code. So far, I got it to work using one of Jose's AfxWindow template sample code.

   sendmessage( hTooltip, TTM_SETMAXTIPWIDTH, 0, 200 )
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9411
  • Windows 10
    • PlanetSquires Software
Re: Multiline tooltip
« Reply #4 on: December 27, 2021, 09:07:57 AM »

Hopefully this will work for you.... it seems to now work okay within WinFBE's generated visual designer code. The 'problem' is that WinFBE does not expose the window handle for any tooltip control that you assign to a control. It is tracked internally by the WinFBE visual designer code (WinFormsX) but it is not readily available to the user.

I have now added a property that will allow you access the window handle for the tooltip.

You will need to download the attachment which contains the updated WinFormsX files. There are only 2 in the zip file and they both need to be copied to your inc folder. For example: \WinFBE_Suite\FreeBASIC-1.07.2-gcc-5.2\inc\WinFormsX   This will overwrite the 2 files that currently exist there.

In your WinFBE visual designer, enable the Load event for your form and you can now set the tooltip code as follows. You may need to play around with the tooltip width depending on the size of your tooltip.

Code: [Select]
''
''
Function frmMain_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
   
   dim newText as wstring * 100 = "Button 1 new text" & chr(10) & "Second line" & chr(10) & "third line"
   frmMain.Button1.Tooltip = newText
   
   newText = "Label 1 new text" & chr(10) & "Second line" & chr(10) & "third line"
   frmMain.Label1.Tooltip = newText

   sendmessage( frmMain.Button1.hWindowToolTip, TTM_SETMAXTIPWIDTH, 0, 200 )
   sendmessage( frmMain.Label1.hWindowToolTip, TTM_SETMAXTIPWIDTH, 0, 200 )

   Function = 0
End Function

Hope this works for you!
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

SeaVipe

  • Senior Member
  • ***
  • Posts: 407
  • Windows 10
Re: Multiline tooltip
« Reply #5 on: December 27, 2021, 03:01:09 PM »

That works great, Paul, thanks.
Regular ToolTips work as desired. Balloon ToolTips with more than 1 CR inserted in the text popup properly but with the rounded corners squared off, other than that they also work properly.

Here is all the code needed:
Code: [Select]
' Form's Load
sendmessage( frmMainJ.lvJournal.hWindowToolTip, TTM_SETMAXTIPWIDTH, 0, 500 )
' ListView MouseMove

' Set tooltiptext.
Dim as long Row, Col
Var HT = sender.HitTest( Row, Col )
If HT = -1 Then
    sender.ToolTip = ""
    Return 0
End If
Dim newTip As WString * 500 = Trim(js(jdb.RecPtr).Body(row + 1))
sender.ToolTip = newTip
I like the appearance of the squared off BalloonToolTip.
Logged
Clive Richey
You're Either Part Of The Solution, Or You're The Problem.
#StaySafe, Always  Keep A Safe #SocialDistance, #WashYourHands Often and please, #StayHome!