Is it possible to have <CR> in a text with Gadgettooltip ?
Is it possible to have <CR> in a text with Gadgettooltip ?
Hi all,
I would like to put some few lines, but chr(10) and chr(13) are not interpreted.
If not, any alternative ?
I would like to put some few lines, but chr(10) and chr(13) are not interpreted.
If not, any alternative ?
Purebasic 6.04 64 bits - Windows 11 Pro 64 bits 23H2
Re: Is it possible to have <CR> in a text with Gadgettooltip
This works on Linux, does it not work on Windows?
Code: Select all
GadgetToolTip(0, "Line 1" + #CRLF$ + "Line 2")
Re: Is it possible to have <CR> in a text with Gadgettooltip
Unfortunately no, It prints two more squares on the same line.
Purebasic 6.04 64 bits - Windows 11 Pro 64 bits 23H2
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Is it possible to have <CR> in a text with Gadgettooltip
Wow, that is a surprise. Probably can do it via the API. There is an API solution using balloon tips, can't remember who published the following code, works well:
Code: Select all
Enumeration
#Window
#StrGadget
EndEnumeration
Procedure TestWindow()
;-------------------
If OpenWindow(#Window, 0, 0, 200, 100, "Tooltip", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(#StrGadget, 10, 40, 180, 20,"")
;GadgetToolTip(#StrGadget, "Line 1" + #CRLF$ + #CRLF$ + "Line 2")
EndIf
EndProcedure
Procedure BalloonTip(iWindowID.i, iGadget.i, sTip.s , sTitle.s, iIcon.i)
;-----------------------------------------------------------------------
iToolTip = CreateWindowEx_(0,"ToolTips_Class32","",#WS_POPUP | #TTS_NOPREFIX | #TTS_BALLOON,0,0,0,0,iWindowID,0,GetModuleHandle_(0),0)
SendMessage_(iToolTip,#TTM_SETDELAYTIME, #TTDT_AUTOPOP, 30000)
SendMessage_(iToolTip,#TTM_SETTIPTEXTCOLOR,GetSysColor_(#COLOR_INFOTEXT),0)
SendMessage_(iToolTip,#TTM_SETTIPBKCOLOR,GetSysColor_(#COLOR_INFOBK),0)
SendMessage_(iToolTip,#TTM_SETMAXTIPWIDTH,0,280)
Balloon.TOOLINFO\cbSize=SizeOf(TOOLINFO)
Balloon\uFlags = #TTF_IDISHWND | #TTF_SUBCLASS
Balloon\hwnd = GadgetID(iGadget)
Balloon\uId = GadgetID(iGadget)
Balloon\lpszText = @sTip
SendMessage_(iToolTip, #TTM_ADDTOOL, 0, @Balloon)
If (sTitle > "")
SendMessage_(iToolTip, #TTM_SETTITLE, iIcon, @sTitle)
EndIf
EndProcedure
TestWindow()
BalloonTip(#Window, #StrGadget, "Line 1" + #CRLF$ + "Line 2" + #CRLF$ + "Line 3" , "multi-line tip", 0)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Is it possible to have <CR> in a text with Gadgettooltip
...yes, you can modify the BalloonTip procedure to get a self-wrapping regular tooltip:
Code: Select all
Procedure Tip(iWindowID.i, iGadget.i, sTip.s)
;--------------------------------------------
iToolTip = CreateWindowEx_(0,"ToolTips_Class32","",#WS_POPUP | #TTS_NOPREFIX,0,0,0,0,iWindowID,0,GetModuleHandle_(0),0)
SendMessage_(iToolTip,#TTM_SETTIPTEXTCOLOR,GetSysColor_(#COLOR_INFOTEXT),0)
SendMessage_(iToolTip,#TTM_SETTIPBKCOLOR,GetSysColor_(#COLOR_INFOBK),0)
SendMessage_(iToolTip,#TTM_SETMAXTIPWIDTH,0,200)
Tip.TOOLINFO\cbSize=SizeOf(TOOLINFO)
Tip\uFlags = #TTF_IDISHWND | #TTF_SUBCLASS
Tip\hwnd = GadgetID(iGadget)
Tip\uId = GadgetID(iGadget)
Tip\lpszText = @sTip
SendMessage_(iToolTip, #TTM_ADDTOOL, 0, @Tip)
EndProcedure
TestWindow()
Tip(#Window, #StrGadget, "Long long long long long long long long long long long long long long long long long tip")
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Is it possible to have <CR> in a text with Gadgettooltip
Oh yes, thanks a lot !
Nice one with BallonTip. Exactly what I expected.
However, do you think the wierd #CRLF$ behaviour (2 squares in the GadgetToolTip instead of real chr(13) and chr(10) LineFeed and Carriage Return) must be considered as a bug under Windows ? Seems to be OK under Linux regarding Trond experience.
Same behaviour for Windows users ?
Nice one with BallonTip. Exactly what I expected.
However, do you think the wierd #CRLF$ behaviour (2 squares in the GadgetToolTip instead of real chr(13) and chr(10) LineFeed and Carriage Return) must be considered as a bug under Windows ? Seems to be OK under Linux regarding Trond experience.
Same behaviour for Windows users ?
Purebasic 6.04 64 bits - Windows 11 Pro 64 bits 23H2
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Is it possible to have <CR> in a text with Gadgettooltip
Maybe not a bug, it seems that Windows simply does not support CrLf in a regular tooltip. Let's wait for a definitive opinion from one of the API experts.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Is it possible to have <CR> in a text with Gadgettooltip
Code: Select all
GadgetToolTip(0, "Line 1" + chr(13) + "Line 2")
MacBook Pro-M1 (2021), Sonoma 14.4.1, PB 6.10LTS M1
- DoubleDutch
- Addict
- Posts: 3219
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Re: Is it possible to have <CR> in a text with Gadgettooltip
Maybe it's a bug then, I personally would like multiline tool tips to be standard (maybe in a nice Christmas present update Fred?).
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
Re: Is it possible to have <CR> in a text with Gadgettooltip
It's not a bug in PB. Tooltips are provided and handled by the OS. Windows simply doesn't support it.
Windows does not support many things regarding CR and LF.
Another example: http://purebasic.fr/english/viewtopic.php?f=18&t=44201
According to Vera, the Debugger on Linux creates new lines at CR and LF. Windows displays [] or nothing at all.
Windows does not support many things regarding CR and LF.
Another example: http://purebasic.fr/english/viewtopic.php?f=18&t=44201
According to Vera, the Debugger on Linux creates new lines at CR and LF. Windows displays [] or nothing at all.
Re: Is it possible to have <CR> in a text with Gadgettooltip
That's just not correct. Absence of CRLF-support and/or Multiline-Tooltips belongs to PB, not to windows.TomS wrote:It's not a bug in PB. Tooltips are provided and handled by the OS. Windows simply doesn't support it.
See WinAPI-example.
Re: Is it possible to have <CR> in a text with Gadgettooltip
TomS:inSANE wrote:That's just not correct. Absence of CRLF-support and/or Multiline-Tooltips belongs to PB, not to windows.TomS wrote:It's not a bug in PB. Tooltips are provided and handled by the OS. Windows simply doesn't support it.
Just read the corresponding chapter in the MSDN:
The following code example (which uses the nice code from netmaestro to obtain the ToolTip handle)MSDN wrote:Implementing Multiline Tooltips
Multiline tooltips allow text to be displayed on more than one line. They are supported by version 4.70 and later of the common controls. Your application creates a multiline tooltip by sending a TTM_SETMAXTIPWIDTH message, specifying the width of the display rectangle.
demonstrates how to display a ToolTip created with the PureBasic function GadgetToolTip() and
display that TooltTip with 2 lines using a CR. You also could use #LF$ or #CRLF$ instead of #CR$:
Code: Select all
; ToolTipID() code from netmaestro
; http://www.purebasic.fr/english/viewtopic.php?t=36765&start=0
Procedure EnumProc(hwnd, lparam)
Shared ctrl
cn$ = Space(100)
GetClassName_(hwnd, @cn$, 99)
If UCase(cn$) = "TOOLTIPS_CLASS32"
With ti.TOOLINFO
\cbSize = SizeOf(TOOLINFO)
\hwnd = GetParent_(ctrl)
\uid = ctrl
EndWith
If SendMessage_(hwnd, #TTM_GETTOOLINFO, 0, @ti)
PokeI(lparam, hwnd)
ProcedureReturn 0
Else
ProcedureReturn 1
EndIf
Else
ProcedureReturn 1
EndIf
EndProcedure
ProcedureDLL.i ToolTipID(gadget)
Shared ctrl
ctrl = gadget
EnumWindows_(@EnumProc(),@TTID)
ProcedureReturn TTID
EndProcedure
OpenWindow(0, 1800, 400, 270, 100, "GadgetTooltip")
ButtonGadget(0, 10, 30, 250, 30, "Button with Tooltip")
GadgetToolTip(0, "Multiline Tooltip" + #CR$ + "with CR")
SendMessage_(ToolTipID(GadgetID(0)), #TTM_SETMAXTIPWIDTH, 0, 200)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: Is it possible to have <CR> in a text with Gadgettooltip
@inSANE & Shardik: Thanks.
I guess I was to quick to answer, based on the experience with the debugger in my thread. But maybe that's an PB issue, too.
I guess I was to quick to answer, based on the experience with the debugger in my thread. But maybe that's an PB issue, too.
Re: Is it possible to have <CR> in a text with Gadgettooltip
I think this should go to the Windows related bug section then.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Re: Is it possible to have <CR> in a text with Gadgettooltip
I assume, it's not a bug. It's more like an unsupported feature (as there are on many other controls as well).c4s wrote:I think this should go to the Windows related bug section then.
So I would say, it's something for the "Feature Requests and Wishlists" section.