Example with WinApi - Multiline Tooltip:
Code: Select all
EnableExplicit
Procedure.i ToolTip(Gadget.i,Text.s)
Protected hwnd.i
Protected ti.TOOLINFO
If IsGadget(Gadget)
ti\cbSize = SizeOf(TOOLINFO)
ti\uFlags = #TTF_SUBCLASS
ti\hWnd = GadgetID(Gadget)
ti\hInst = GetModuleHandle_(#Null)
ti\lpszText = SysAllocString_(Text)
ti\rect\left = GadgetX(Gadget)
ti\rect\top = GadgetY(Gadget)
ti\rect\right = ti\rect\left + GadgetWidth(Gadget)
ti\rect\bottom = ti\rect\top + GadgetHeight(Gadget)
hwnd = CreateWindowEx_(#Null,#TOOLTIPS_CLASS,#Null,
#WS_POPUP|#TTS_ALWAYSTIP,
#CW_USEDEFAULT,#CW_USEDEFAULT,#CW_USEDEFAULT,
#CW_USEDEFAULT,ti\hWnd,#Null,ti\hInst,#Null)
If hwnd
SendMessage_(hwnd,#TTM_ADDTOOL,#Null,@ti)
SendMessage_(hwnd,#TTM_SETMAXTIPWIDTH,#Null,150)
ProcedureReturn #True
EndIf
If ti\lpszText
SysFreeString_(ti\lpszText)
EndIf
EndIf
ProcedureReturn #False
EndProcedure
Procedure.i Main()
If OpenWindow(0,0,0,800,600,"Dummy",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ButtonGadget(1,10,10,200,30,"Hello World!")
ToolTip(1,"Hello World!" + #CR$ + "How does this magic work?" + #CR$ + "Black Magic!!!!")
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
CloseWindow(0)
EndIf
ProcedureReturn #Null
EndProcedure
End Main()