PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Rolf Brandt on November 23, 2009, 08:35:54 AM

Title: Changing Text and Tooltip text of Toolbar at runtime
Post by: Rolf Brandt on November 23, 2009, 08:35:54 AM
How can I change the text and Tooltip text of a Toolbar at runtime?
Title: Re: Changing Text and Tooltip text of Toolbar at runtime
Post by: Paul Squires on November 23, 2009, 06:11:15 PM
Here is how to change the Text:


         Local tButtonInfo As TBBUTTONINFO
         Local st          As String

         st = "New Text"
         
         tButtonInfo.cbSize  = SizeOf(TBBUTTONINFO)
         tButtonInfo.dwMask  = %TBIF_TEXT
         tButtonInfo.pszText = StrPtr(st)
         tButtonInfo.cchText = Len(st)
         
         SendMessage GetDlgItem(hWndForm, IDC_FRMCLASSBUILDER_TOOLBAR1), %TB_SETBUTTONINFO, IDC_FRMCLASSBUILDER_TOOLBAR1_CLASSES, VarPtr(tButtonInfo)

Title: Re: Changing Text and Tooltip text of Toolbar at runtime
Post by: Paul Squires on November 23, 2009, 06:19:47 PM
With regards to the ToolTips, you will need to override the code already generated by FF3. To do that, you create your own code in the WM_NOTIFY handler and then return a FUNCTION = %TRUE from the function.


Function FRMCLASSBUILDER_WM_NOTIFY ( _
                                   hWndForm     As Dword,     _  ' handle of Form
                                   idCtrl       As Dword,     _  ' control ID
                                   ByVal pNMHDR As NMHDR Ptr  _  ' pointer to NMHDR structure
                                   ) As Long

   Local pTBN            As TBNOTIFY Ptr
   Local lpToolTip       As TOOLTIPTEXT Ptr
   Local zTempString     As Asciiz * %MAX_PATH


   ' Handle any Toolbar Button tooltips
   pTBN = pNMHDR
   If @pTBN.hdr.Code = %TTN_NEEDTEXT Then
      lpToolTip = pNMHDR
      Select Case @lpToolTip.hdr.idFrom
         Case IDC_FRMCLASSBUILDER_TOOLBAR1_CLASSES:    zTempString = "ToolTip1"
         Case IDC_FRMCLASSBUILDER_TOOLBAR1_INTERFACES: zTempString = "ToolTip2"
         Case IDC_FRMCLASSBUILDER_TOOLBAR1_PROPERTIES: zTempString = "ToolTip3"
         Case IDC_FRMCLASSBUILDER_TOOLBAR1_METHODS:    zTempString = "ToolTip4"
      End Select
      @lpToolTip.lpszText = VarPtr(zTempString)
     
      Function = %TRUE
   End If

End Function


Title: Re: Changing Text and Tooltip text of Toolbar at runtime
Post by: Rolf Brandt on November 23, 2009, 06:23:23 PM
Thank you, Paul, I will try it out.

Rolf