Copyright: © 1996 by xDev Inc. Peter Stadelmann
Citation: © 1996 by xDev Inc. Peter Stadelmann


Contents
VB Toolbar

How To

Adding a Toolbar onto Your Project

Adding Tooltips to your Toolbar

Displaying Buttons in some state

Adding Setup Form for your Toolbar

Reference

g_AddToolbar

g_AddToolbarButton

g_CalcToolbarButtons

g_PaintToolbar

g_ResizeToolbar

g_SetToolbarStatushelp

g_SetToolbarTooltip

giToolbarClicked

giToolbarMouseMove

Know How

Measurements of the basic bitmap

This Toolbar ist written in pure VB. Runs in VB3 and VB4. Runs under Windows 3.11 and Windows 95 and Windows NT 3.51 and Windows NT 4.0. Set the prefered Windowstyle automaticly.

Copyright by

xDev Inc.

Peter Stadelmann	Phone	0041 41 280 93 39

Chalet Lindenberg	Fax	0041 41 280 93 09

CH-6025 Neudorf / Switzerland	Email	74017,3204@compuserve.com


Adding a Toolbar onto Your Project

1. Design

Just add a picturebox in your form or MDI Form. This picturebox can have all the default styles. Name this first picturebox PictureToolbar.

Then add a second picturebox (into this picturebox) in this form. Name this second picturebox PictureBitmap. Set the Visible propertie to false and set the Autoredraw and the Autosize propertie to true.

Then add in the picture propertie your basicbitmap.

2. Coding

Some little code must be added:

On the PictureToolbar_Mousedown add the code below:

iClicked = giToolBarClicked(PictureToolbar,X,Y)

On the PictureToolbar_Resize add the code below:

g_PaintToolbar PictureToolbar

On the Form_load or MDIform_load event you must add the initialising for the toolbar:

g_AddToolbar PictureToolbar, PictureBitmap.hDC

g_AddToolbarButton PictureToolbar.DataField,1,-1,´´

g_AddToolbarButton PictureToolbar.DataField,2, 1,´Creates a new Document@New´

g_ResizeToolbar PictureToolbar

g_CalcToolbarButtons PictureToolbar

3. Adding needed Modules

Choose Add File... from the VB file menu. Select xtoolbar.bas and press ok.

4. Run the form

Press F5 from VB to run the form with a new toolbar with one button


Measurements of the basic bitmap

The basic bitmap contents all the bitmap for the toolbar, in color and in grayed, small and big pictures.

The small buttons are:

16 Pixel width

15 Pixel height

The big buttons are:

24 Pixel width

23 Pixel height

The basic bitmap has a total height of 76 Pixel

Example:


giToolbarClicked

Detects if a toolbarbutton is clicked and returns the button number.

Parameters:	Picturebox (your toolbar)

X and Y   (Mouseposition)

Returns:	Integer (button number)


Adding Tooltips to your Toolbar

The toolbarbuttons contains two types of shorthelp. One ist the statushint and one is the tooltip.

The statushint is the left part (separated with a @) of the last parameter when you create a button with g_AddToolbarButton. If no @ is in the text, the full text is the statushint and the button cannot display an tooltip.

The tooltip is the right part (separated with a @) of the last parameter when you create a button with g_AddToolbarButton.

1. Setting the statushint

You can assign any label in your form for displaying the longhelp text. Just add then code below:

g_SetToolbarStatushelp MyLabel

2. Setting the tooltip

You can assign any label in your form for displaying the longhelp text. Just add then code below:

g_SetToolbarTooltip MyTooltipLabel

You can use your one Tooltip engine for that or can use our XTIPS.FRM form. In this case the code must be follow:

g_SetToolbarTooltip frmxTooltip.lblTip

3. Insert the Event

For adding Tooltips and statushints into your toolbar, you must detect the Mousemove on the toolbar.

On the PictureToolbar_MouseMove add the code below:

iOver = giToolbarMouseMove(PictureToolbar,X,Y)


XTOOLBAR.BAS

Visual basic source for the toolbar.


g_PaintToolbar

Paints the toolbar new


g_AddToolbar

Adds a new toolbar to the toolbar collection


g_AddToolbarButton

Adds a button to a toolbar


g_ResizeToolbar

Set the size of the toolbar and buttons


g_CalcToolbarButtons

Recalculates all positions of all buttons in the toolbar


g_SetToolbarStatushelp

Set the internal label for the statushint text to the label given.


giToolbarMouseMove

Set the Tooltip and the Shorthelptext when th mouse is over a button. Returns the button number where the mouse is over. Otherwise returns 0.


g_SetToolbarTooltip

Set the internal label for the tooltip text to the label given.


Adding Setup Form for your Toolbar

1. Adding needed forms

Choose Add File... from the VB file menu. Select XTBSETUP.FRM and press ok.

2. Add Code

In a menü or command button click event add the code below

Load frmxToolbarSetup

frmxToolbarSetup.IniFile = "Sample.ini"

If frmxToolbarSetup.Tag = "Changed" Then

g_ResizeToolbar Picture1

g_CalcToolbarButtons Picture1

 Draw all Buttons new

g_DrawButton 2, 0 ...

   	End If

Unload frmxToolbarSetup


Displaying Buttons in some state

If you like to display your buttons, you mus add  the g_DrawButton command.


g_DrawButton

Displays a button in a state

Parameters:	button number

State

0 = Up

1 = Down

2 = Disabled (grayed)