Mega Code Archive

 
Categories / Delphi / VCL
 

Add chevron to TToolbar if some buttons are invisible

Title: add chevron to TToolbar if some buttons are invisible Friends, I sure you saw the cool feature of toolbar in all products of Microsoft (Internet Explorer, MS Office, Outlook Express etc) - when width of toolbar is less than total width of all buttons, then in right side of toolbar you see the new button with arrows (chevron sigh) and list of invisible buttons opened like popup menu by click on chevron. Today I want to show how to add the chevron button in standard Delphi application and don't use the third-party components. Please note that most components from third-party companies don't use this feature of common control in Windows - they created own control and draws everything (all buttons, sll bars etc) self. As I prefer to use standard controls only (for future compartibility), I use the standard TCoolbar and TToolbar from Win32 palette in Delphi IDE which are wrappers for common controls in published library (like TEdit, TButton, TTreeView, TListView etc) So lets's start. You must drop the TCoolbar control to your form, add the TToolbar to some band of coolbar and add some other bands for coolbar (note that you must have a few bands for correct work of chevron). For your TToolbar you may add any number of buttons and don't forget to set the AutoSize property in False. The next code you may call in OnCreate event of form or in OnResize event (form or coolbar): type