attached please find a little Proc to create multilined ToolTips (not Balloon-Tooltips) for Windows-OS (which is supported by PB natively on Linux and OSX):
Code: Select all
Procedure GadgetToolTipML(hwndParent, Text.s, Width = 0)
If IsGadget(hwndParent) And Not IsWindow_(hwndParent) ; Allow, to enter either the PB-#Gadget or a Window-/Gadget-ID
hwndParent = GadgetID(hwndParent)
EndIf
Protected hwndTT = CreateWindowEx_(#WS_EX_TOPMOST, #TOOLTIPS_CLASS, #Null, #WS_POPUP | #TTS_NOPREFIX | #TTS_ALWAYSTIP, #CW_USEDEFAULT, #CW_USEDEFAULT, #CW_USEDEFAULT, #CW_USEDEFAULT, hwndParent , #Null, GetModuleHandle_(0), #Null)
SetWindowPos_(hwndTT, #HWND_TOPMOST, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_NOACTIVATE)
Protected ti.TOOLINFO
ti\cbSize = SizeOf(TOOLINFO);
ti\uFlags = #TTF_SUBCLASS;
ti\hwnd = hwndParent;
ti\hinst = #Null
ti\lpszText = @Text
GetClientRect_(hwndParent, @ti\rect);
SendMessage_(hwndTT, #TTM_ADDTOOL, 0, @ti)
If Width
SendMessage_(hwndTT, #TTM_SETMAXTIPWIDTH, 0, Width)
ElseIf FindString(Text, #CRLF$, 1)
SendMessage_(hwndTT, #TTM_SETMAXTIPWIDTH, 0, 9999)
EndIf
EndProcedure
Text.s = "The quick brown fox jumps over the lazy dog. Ein Neger mit Gazelle zagt im Regen nie."
CRText.s = "The quick brown fox jumps" + #CRLF$ + "over the lazy dog." + #CRLF$ + "Ein Neger" + #CRLF$ + "mit Gazelle zagt im Regen nie."
If OpenWindow(0,0,0,300,125,"MultiLine ToolTips", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0,10,15,280,20,"Long single lined ToolTip")
ButtonGadget(1,10,40,280,20,"Long auto-wordwrap ToolTip")
ButtonGadget(2,10,65,280,20,"Short auto-wordwrap ToolTip")
ButtonGadget(3,10,90,280,20,"ToolTip with #CRLF wordwrap")
GadgetToolTipML(WindowID(0), "I'm a Window, and I'm proud to have my own TooltTip. :-)",100)
GadgetToolTipML(GadgetID(0), Text) ; You can either use a WindowID() / GadgetID()
GadgetToolTipML(1, Text, 300) ; or the PB-#Gadget as first Parameter.
GadgetToolTipML(2, Text, 100)
GadgetToolTipML(3, CRText)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Maybe someone will have some use for it.