Announcement

Collapse
No announcement yet.

Changing tool bar button text????

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Guest's Avatar
    Guest replied
    Hi Bern,
    Just a thought, but you might want to also go over to msdn
    and check out the TB_SETBUTTONINFO message too.

    Adam

    ------------------

    Leave a comment:


  • Bern Ertl
    replied
    Thanks Borje, I'll experiment with that.



    ------------------
    Bernard Ertl

    Leave a comment:


  • Borje Hagsten
    replied
    A tricky one. Strange that Microsoft hasn't given us a way to do this
    easily. Here is what I have used. I add a string, delete a button and
    create it again, with pointer to added string. It works, but there may
    (must) be better ways. You probably have to adjust some things, like
    changing tb.iString, so it really points to the new, added string:
    Code:
      LOCAL tb AS TBBUTTON, txt AS STRING
      txt = " Changed! " & $NUL & $NUL 'add a string to the toolbar's string list
      SendMessage hToolBar, %TB_ADDSTRING,  0, STRPTR(txt)
     
      tb.fsState   = %TBSTATE_ENABLED
      tb.fsStyle   = %TBSTYLE_BUTTON
      tb.iBitmap   = %STD_FILEOPEN
      tb.idCommand = %IDM_OPEN
      tb.iString = 7 'was 6, added one, so use the new, nr 7..
     
      SendMessage hToolBar, %TB_DELETEBUTTON,  0, 0          'delete old button
      SendMessage hToolBar, %TB_INSERTBUTTON,  0, VARPTR(tb) 'insert new at same pos (it will use the new string)
    BTW, a word of warning: Changing the text may also change the size of
    all buttons in the toolbar, if text is wider. Be careful, so buttons
    don't end up becoming too wide for the toolbar.
    ------------------



    [This message has been edited by Borje Hagsten (edited February 16, 2001).]

    Leave a comment:


  • Bern Ertl
    started a topic Changing tool bar button text????

    Changing tool bar button text????

    I've been experimenting with Lance's DDT tool bar sample and I cannot figure out how to change the text for a button during runtime. Ie. when a user clicks on a button, I'd like to change the text associated with it.

    I've tried sending a second %TB_ADDSTRING message with a new string (complete), but that didn't work. I don't see any other messages in my Win32 Help file that would do it either...

    Help!



    ------------------
    Bernard Ertl
Working...
X