Flat toolbars (API created)
By: Ramon Guerrero Date: 04/07/1998
File:

rgtoolbarapi.exe

Size:

97.5 KB

Download now!

This project creates perfect flat-style toolbars as ones in Microsoft Office 97 applications or in IE4.

To create your toolbar set:

  1. Add the 3 standard modules and the 3 class modules to your project once you have unpacked them.

  2. Copy the Form_Load event from the example prject and edit it.

  3. In the (Declarations) section, edit the Tool(x) declaration, where x is the number of toolbars less 1.

  4. In the Form_Load event add a line a this for each toolbar: MakeFileTrans imgPictures(x), App.Path & "\Image.bmp" where Image.bmp is a bitmap file containing the icons for the toolbar. To draw transparent background, fill with colour 0,255,255. ImgPictures(x) is a hidden image control to hold the image in memory. (x) is the index of the toolbar (form 0).

  5. Then add a line as this for each toolbar: Tool(x).ImageSource imgPictures(x), to assign icons to toolbars. Replace x with the toolbar index.

  6. Use this block of instructions for each toolbar:

    With Tool(
    x)
    Set .Parent = Me
    .CreateToolbar
    iconsize
    DoEvents
    .AddButton
    i, tooltip, iconindex
    .AddButton
    i, tooltip, iconindex
    .AddButton
    i, tooltip, iconindex
    ...........
    .and so on.
    ...........
    End With


    x is the toolbar index, iconsize is the size of the icons (16=Small, 32=Large), i is the progressive index of the button, tooltip is a string specifying the tooltip of the button, iconindex is the position if the icon in the bitmap file.

  7. The add a block as this.

    With Tips
    .Create
    .AddTool Tool(
    x).GetToolbarHwnd
    .AddTool Tool(
    x).GetToolbarHwnd
    .AddTool Tool(
    x).GetToolbarHwnd
    ...........
    .and so on.
    ...........
    End With

    x is the index of the toolbar (from 0).

  8. Finally, add a block like this.

    With Rebar
    Set .Parent = Me
    Set .ImageForRebar = Image1
    .Create
    .AddBands
    toolbartitle, 0, Tool(x).GetToolbarHwnd, AddNewRow, 5
    .AddBands
    toolbartitle, 0, Tool(x).GetToolbarHwnd, AddNewRow, 5
    .AddBands
    toolbartitle, 0, Tool(x).GetToolbarHwnd, AddNewRow, 5
    ...........
    .and so on.
    ...........
    End With

    toolbartitle is the (optional) title for the toolbar
    x is the index of the toolbar (from 0).

  9. At the end of the procedure, add the following line.

    SubClass Me.hWnd

If you found this procedure too difficult, look for a OCX version of the toolbars in our site: it may be easier for you, but it gives worse performance.

That's it! Toolbars are created. You can discover more things (such as buttons with text) by reading the code of the example included in the archive.

Run the self-extracting ZIP and specify a directory to unzip files to. In your project, add the 6 modules and follow the instructions above. You can also watch how the provided example works and discover more functions!

Click Here!


Visual Basic Programming Zone is a website by Lorenzo Dalla Vecchia.
Webmaster's e-mail: webmaster@vbprogzone.cjb.net
Hosted by InWind: www.inwind.it