Board index » delphi » TToolBar bug/feature?

TToolBar bug/feature?

Can somebody please tell me if this is a Delphi bug or Microsoft feature.
Does anybody know of a workaround?

Try this:
- create new app in D4
- put onto form TToolBar
- create new button in the ToolBar1
- create a button on the Form1
- assign to its OnClick event:
  with ToolButton1 do begin
    Style := tbsDropDown;
    Width := 41;
  end;
- run the program
- click the Button1
- toolbar button will chang to DropDown button but won't change the width!

You can reproduce similar behaviour in Delphi IDE.
- create a TToolBar and TToolButton as before
- change the ToolButton1 style to tbsDropDown
- toolbutton will change the style but not the width
- if you close and reopen the form, toolbutton will reappear correctly
- however, in Delphi IDE you can enter new width for the toolbutton and
button will be immediately resized

I desperately need a workaround for this stupid behaviour! Thanks in
advance!

Primoz

 

Re:TToolBar bug/feature?


Quote
>Can somebody please tell me if this is a Delphi bug or Microsoft feature.
>Does anybody know of a workaround?

Well, I must answer myself, it seems.

Quote
>  with ToolButton1 do begin
>    Style := tbsDropDown;
>    Width := 41;
>  end;

Add to this:
ToolBar1.Perform(CM_RECREATEWND, 0, 0);

And the button will display correctly!

Primoz

Other Threads