Changing Text and Tooltip text of Toolbar at runtime

Started by Rolf Brandt, November 23, 2009, 08:35:54 AM

Previous topic - Next topic

Rolf Brandt

How can I change the text and Tooltip text of a Toolbar at runtime?
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Paul Squires

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)

Paul Squires
PlanetSquires Software

Paul Squires

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


Paul Squires
PlanetSquires Software

Rolf Brandt

Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)