PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: tool tips  (Read 676 times)

raymw

  • FireFly3 User
  • Senior Member
  • *
  • Posts: 208
tool tips
« on: June 28, 2018, 01:24:24 PM »

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.
Logged

Josť Roca

  • FireFly3 Registered User
  • Master Member
  • *
  • Posts: 3103
    • Jos
Re: tool tips
« Reply #1 on: June 28, 2018, 06:14:12 PM »

?

Can you post the changed function?

raymw

  • FireFly3 User
  • Senior Member
  • *
  • Posts: 208
Re: tool tips
« Reply #2 on: June 28, 2018, 08:00:30 PM »

This was the code in the codegen_main_xxx.bas file
Code: [Select]
Function 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
Code: [Select]
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
Code: [Select]
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.
« Last Edit: June 28, 2018, 08:04:01 PM by raymw »
Logged

Josť Roca

  • FireFly3 Registered User
  • Master Member
  • *
  • Posts: 3103
    • Jos
Re: tool tips
« Reply #3 on: June 28, 2018, 09:28:45 PM »

Yes. The limitation of 80 characters only applies if you use the szText member of the NMTTDISPINFO structure.

Jean-pierre Leroy

  • FireFly3 Registered User
  • Senior Member
  • *
  • Posts: 465
  • expect nothing, be prepared for everything ...
Re: tool tips
« Reply #4 on: July 05, 2018, 11:37:36 AM »

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
Logged

Josť Roca

  • FireFly3 Registered User
  • Master Member
  • *
  • Posts: 3103
    • Jos
Re: tool tips
« Reply #5 on: July 05, 2018, 11:48:01 AM »

Indeed. REM or remove this line in ToolTipCtrl.inc:

IF LEN(strTooltipText) > 79 THEN strTooltipText = LEFT$(strTooltipText, 79)

raymw

  • FireFly3 User
  • Senior Member
  • *
  • Posts: 208
Re: tool tips
« Reply #6 on: July 08, 2018, 12:30:15 PM »

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?
Logged