The Toolbar


There are only two things left to be done in this chapter: add glyphs to the most often used actions and then add these actions to the toolbar.

First, add a TImageList component to the Designer Surface, rename it Normal, and then add glyphs for the New, Open, Save, Undo, Cut, Copy, Paste, Delete, and Find actions (see Figure 16-17). After you add these images to the TImageList component, assign the TImageList component to the TActionList, TToolbar, and TMainMenu components and then open the Action List editor and assign the glyphs to the appropriate actions.

image from book
Figure 16-17: The images used in the text editor

When you're done assigning glyphs to the actions, select the toolbar and right-click it to display the toolbar's context menu. The context menu offers you the New Button option to create a new toolbar button and the New Separator option to create a separator item that enables you to visually group buttons. All that you have to do now is add several buttons to the toolbar and assign an action to the Action property of each button.

If you want, you can also modify the following two properties to make the toolbar more attractive:

  1. Set the AutoSize property to True to remove the empty space on the toolbar.

  2. Set the ShowCaptions property to True to display button captions (if you do this, you'll have to remove the ampersand characters and dots from the button captions).

Also, you can improve the look of the disabled toolbar buttons by adding another TImageList component to the Designer Surface to hold disabled glyphs. Here's what you have to do to add disabled glyphs to the toolbar:

  1. Add another TImageList component to the Designer Surface.

  2. Rename it Disabled.

  3. Add disabled glyphs to the image list (the disabled glyphs in the GlyFX folder end with _d).

  4. Make sure that the index of each disabled glyph matches the index of the normal glyph in the Normal image list (see Figure 16-18).

    image from book
    Figure 16-18: Normal and disabled image lists

  5. Assign the disabled image list to the toolbar's DisabledImages property.

After you've added the disabled glyphs to the toolbar, you're done. The text editor is completely finished. You can see the final product in Figure 16-19.

image from book
Figure 16-19: The best text editor in the galaxy



Inside Delphi 2006
Inside Delphi 2006 (Wordware Delphi Developers Library)
ISBN: 1598220039
EAN: 2147483647
Year: 2004
Pages: 212
Authors: Ivan Hladni

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net