Firefly tooltips are currently limited to 80 characters, but need more. I've copied the Function FF_AddTooltip and renamed it in my program, and have called it on form initialising, with appropriate longer strings. This seems to work OK. It also seems to make my workflow better, since the text entry for the tip is in the basic editor, and can be changed more readily, and can be set default to balloon.
?
Can you post the changed function?
This was the code in the codegen_main_xxx.bas fileFunction FF_AddTooltip( BYVAL hwnd AS HWND, strTooltipText AS STRING, BYVAL bBalloon AS Long ) As HWND
IF hwnd = 0 Then Exit Function
Dim hwndTT AS HWND
Dim dwStyle As Long
dwStyle = WS_POPUP OR TTS_NOPREFIX OR TTS_ALWAYSTIP
IF bBalloon THEN dwStyle = dwStyle OR TTS_BALLOON
hwndTT = CreateWindowEx(WS_EX_TOPMOST, "tooltips_class32", "", dwStyle, 0, 0, 0, 0, 0, Cast(HMENU, Null), 0, ByVal Cast(LPVOID, Null))
IF hwndTT = 0 THEN Exit Function
SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE OR SWP_NOSIZE OR SWP_NOACTIVATE)
' // Register the window with the tooltip control
Dim tti AS TOOLINFO
tti.cbSize = SIZEOF(tti)
tti.uFlags = TTF_SUBCLASS
tti.hwnd = hwnd
tti.hinst = GetModuleHandle(BYVAL NULL)
GetClientRect(hwnd, Varptr(tti.rect))
' // The length of the string must not exceed of 80 characters, including the terminating null
IF LEN(strTooltipText) > 79 THEN strTooltipText = LEFT(strTooltipText, 79)
tti.lpszText = STRPTR(strTooltipText)
tti.uId = 0
SendMessage hwndTT, TTM_ADDTOOL, 0, Cast(LPARAM, Varptr(tti))
Function = hwndTT
End Function
I simply copied that function into my program, and fixed it as balloon text only, increased the character count and renamed it Function tip( BYVAL hwnd AS HWND, strTooltipText AS STRING ) As HWND
IF hwnd = 0 Then Exit Function
Dim hwndTT AS HWND
Dim dwStyle As Long
dwStyle = WS_POPUP OR TTS_NOPREFIX OR TTS_ALWAYSTIP
dwStyle = dwStyle OR TTS_BALLOON
hwndTT = CreateWindowEx(WS_EX_TOPMOST, "tooltips_class32", "", dwStyle, 0, 0, 0, 0, 0, Cast(HMENU, Null), 0, ByVal Cast(LPVOID, Null))
IF hwndTT = 0 THEN Exit Function
SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE OR SWP_NOSIZE OR SWP_NOACTIVATE)
' // Register the window with the tooltip control
Dim tti AS TOOLINFO
tti.cbSize = SIZEOF(tti)
tti.uFlags = TTF_SUBCLASS
tti.hwnd = hwnd
tti.hinst = GetModuleHandle(BYVAL NULL)
GetClientRect(hwnd, Varptr(tti.rect))
' // The length of the string must not exceed of 80 characters, including the terminating null
IF LEN(strTooltipText) > 127 THEN strTooltipText = LEFT(strTooltipText, 127)
tti.lpszText = STRPTR(strTooltipText)
tti.uId = 0
SendMessage hwndTT, TTM_ADDTOOL, 0, Cast(LPARAM, Varptr(tti))
Function = hwndTT
End Function
and then in the form initialisation I put code such as
tip(hwnd_frmmain_bmaxg,"this is where you enter the maximum G value. If it is left blank it will be treated as a 0")
Quick and dirty but seems to work OK.
I've not looked into it in detail, but with longer lines it would be nice to be able to alter the display time, but I'm thinking I may alter it to launch a message box.
Yes. The limitation of 80 characters only applies if you use the szText member of the NMTTDISPINFO structure.
Quote from: José Roca on June 28, 2018, 09:58:45 PM
Yes. The limitation of 80 characters only applies if you use the szText member of the NMTTDISPINFO structure.
José,
With PowerBASIC I use your functions Tooltip_AddA() / or Tooltip_AddW() defined in your header TooltipCtrl.inc.
Is-there a way to avoid the limitation to 80 characters ?
Thanks,
Jean-Pierre
Indeed. REM or remove this line in ToolTipCtrl.inc:
IF LEN(strTooltipText) > 79 THEN strTooltipText = LEFT$(strTooltipText, 79)
I was hoping it would be simple to 'hook in' to the tool tip activation, to allow other functions. I would like to be able to highlight a couple of text boxes when the tool tip shows, or launch a message box if tool tip showing for a longer length of time, for example. I had thought that I could use the setfocus function, but it seems only to respond when the button is pressed, not when the cursor hovers over said button. Any ideas?