Toolbar control help

Function help:

Real API_Toolbar_Create (Real Parent Handle, Real Style Flags, Real Extended Style Flags);

This function creates a new tool bar control.

Argument list:
(0) Parent Handle: Identifies the window handle of the window to create this control on.
(1) X: The horizontal position of the control in pixels, relative to the parent window.
(2) Y: The vertical position of the control in pixels, relative to the parent window.
(3) Width: The horizontal size of the control in pixels.
(4) Height: The vertical size of the control in pixels.
(1) Style Flags: The style flags, supports the Global Control Styles, the Common Control Styles and the following styles:

BTNS_AUTOSIZE
Specifies that the toolbar control should not assign the standard width to the button. Instead, the button's width will be calculated based on the width of the text plus the image of the button.

BTNS_BUTTON
Creates a standard button.

BTNS_CHECK
Creates a dual-state push button that toggles between the pressed and nonpressed states each time the user clicks it. The button has a different background color when it is in the pressed state.

BTNS_CHECKGROUP
Creates a button that stays pressed until another button in the group is pressed, similar to option buttons (also known as radio buttons). It is equivalent to combining BTNS_CHECK and BTNS_GROUP.

BTNS_DROPDOWN
Creates a drop-down style button that can display a list when the button is clicked.
This kind of button does not send a primary check command with it's id, but it sends a TBN_DROPDOWN message in name of it's parent control.

BTNS_GROUP
When combined with BTNS_CHECK, creates a button that stays pressed until another button in the group is pressed.

BTNS_SEP
Creates a separator, providing a small gap between button groups. A button that has this style does not receive user input.

(6) Extended Style Flags: This can be any combination of the Global Extended Control Styles.

Return value:
If this function succeeds, it returns the Control ID of the control, otherwise it returns 0.


Real API_Toolbar_AddSystemBitmaps (Real Control ID, Real List Type);

This function uses the default system bitmaps as the image list for the control.
See the System Defined Bitmaps for the bitmap variables.

List types: (argument1)
0: Large Standard Bitmaps
1: Small Standard Bitmaps
2: Large View Bitmaps
3: Small View Bitmaps

Return value:
Returns true (1) if successful, or false (0) otherwise.


Real API_Toolbar_AddButton (Real Control ID, Real Zero Based Button Index, Real Style Flags);

This function adds a new button, without a bitmap nor text, to the toolbar.

See API_Toolbar_Create for the style flags.

A toolbar button has it's own Control ID.

Return value:
Returns the Control ID when succesful, or false (0) otherwise.


Real API_Toolbar_AddButtonText (Real Control ID, Real Zero Based Button Index, String Text );

This function adds a new button, with text, to the toolbar.

A toolbar button has it's own Control ID.

Return value:
Returns the Control ID when succesful, or false (0) otherwise.


Real API_Toolbar_AddButtonImage (Real Control ID, Real Zero Based Button Index, Real Image Number );

This function adds a new button, with an image, to the toolbar.

The image number is the number of the image in the image list assigned to the toolbar.
You can use a variable of the System Defined Bitmaps when you used API_Toolbar_AddSystemBitmaps on this toolbar.

A toolbar button has it's own Control ID.

Return value:
Returns the Control ID when succesful, or false (0) otherwise.


Real API_Toolbar_AutoSize (Real Control ID);

Causes a toolbar to be resized.
You send this message after causing the size of a toolbar to change either by setting the button or bitmap size or by adding text for the first time.

Return value:
No return value.


Real API_Toolbar_SetButtonText (Real Control ID, String Text);

This function changes the text of a toolbar button.
The Control ID must be one returned from a toolbar button creation function.

Return value:
Returns true (1) if successful, or false (0) otherwise.


Real API_Toolbar_SetButtonImage (Real Control ID, Real Image Number);

This function changes the image of a toolbar button.
The Control ID must be one returned from a toolbar button creation function.

Return value:
Returns true (1) if successful, or false (0) otherwise.


Real API_Toolbar_SetButtonState (Real Control ID, Real Image Number);

This function changes the state flags of a toolbar button.
The Control ID must be one returned from a toolbar button creation function.

The state flags:
TBSTATE_CHECKED
The button has the TBSTYLE_CHECK style and is being clicked.

TBSTATE_ELLIPSES
The button's text is cut off and an ellipsis is displayed.

TBSTATE_ENABLED
The button accepts user input. A button that doesn't have this state is grayed.

TBSTATE_HIDDEN
The button is not visible and cannot receive user input.

TBSTATE_INDETERMINATE
The button is grayed.

TBSTATE_MARKED
The button is marked. The interpretation of a marked item is dependent upon the application.

TBSTATE_PRESSED
The button is being clicked.

TBSTATE_WRAP
The button is followed by a line break. The button must also have the TBSTATE_ENABLED state.

A button is standardly created with the TBSTATE_ENABLED flag.

Return value:
Returns true (1) if successful, or false (0) otherwise.


Real API_Toolbar_SetButtonStyle (Real Control ID, Real Style Flags);

This function changes the style flags of a toolbar button.
The Control ID must be one returned from a toolbar button creation function.

See API_Toolbar_Create for the style flags. (Yes, the button uses the same styles as it's parent control)

Return value:
Returns true (1) if successful, or false (0) otherwise.


String API_Toolbar_GetButtonText (Real Control ID);

This function returns the text of the specified button.
The Control ID must be one returned from a toolbar button creation function.

Return value:
Returns the button text.


Real API_Toolbar_GetButtonImage (Real Control ID);

This function returns the image number of the button.
The Control ID must be one returned from a toolbar button creation function.

Return value:
Returns the image number.


Real API_Toolbar_GetButtonImage (Real Control ID);

This function returns the image number of the button.
The Control ID must be one returned from a toolbar button creation function.

Return value:
Returns the image number.


Real API_Toolbar_GetButtonState (Real Control ID);

This function returns the current button state flags.
See API_Toolbar_SetButtonState for the state flags.
The Control ID must be one returned from a toolbar button creation function.

Return value:
Returns the state flags.


Real API_Toolbar_GetButtonStyle (Real Control ID);

This function returns the current button style flags.
See API_Toolbar_Create for the style flags.
The Control ID must be one returned from a toolbar button creation function.

Return value:
Returns the style flags.


Real API_Toolbar_SetImageList (Real Control ID, Real Image List Resource Handle);

This function changes the image list assigned to the toolbar.

Make an image list using API_ImageList_Create.

Return value:
Returns true (1) if successful, or false (0) otherwise.


Real API_Toolbar_SetButtonSize (Real Control ID, Real Width, Real Height);

This function changes the size of the buttons in a toolbar.

Return value:
Returns true (1) if successful, or false (0) otherwise


Real API_Toolbar_DeleteButton (Real Control ID);

This function changes the size of the tab items.
The Control ID must be one returned from a toolbar button creation function.

Return value:
Returns true (1) if successful, or false (0) otherwise


Real API_Toolbar_GetButtonIndex (Real Control ID);
This function returns the zero based index of a toolbar button.
The Control ID must be one returned from a toolbar button creation function.

Return value:
Returns the zero based index of the button.


Real API_Toolbar_MoveButton (Real Control ID, Real Zero Based Index);
This function moves a toolbar button to a new index.
The Control ID must be one returned from a toolbar button creation function.

Return value:
Returns true (1) if successful, or false (0) otherwise


Real API_Toolbar_GetIndexButton (Real Control ID, Real Zero Based Index);
This function returns the Control ID of a button in an toolbar in a specified toolbar.

Return value:
Returns the Control ID of the button or 0 when failed.


Real API_Toolbar_GetButtonCount (Real Control ID);
This function returns the number of buttons in a toolbar.

Return value:
Returns the number of buttons in a toolbar.


Secondary check commands for toolbar controls:

NM_CLICK - A button is clicked with the left mouse button.
NM_DBLCLK- A button is double-clicked with the left mouse button.
NM_RCLICK - A button is clicked with the right mouse button.
NM_RDBLCLK - A button is double-clicked with the right mouse button.

You can use API_Check_TertiaryCommand to get the Control ID of the button the notification is related to.

A toolbar buttons sends also it's own Control ID as primary command when clicked.

Example:

if ( Command == Toolbar1 ) // Check wether the command is sended to Toolbar1
{
Second = API_Check_SecondaryCommand (1);
if (Second == NM_RCLICK ) // Check wether the command is a right click
{
Num = API_Check_TertiaryCommand (1); // Get the button number
show_message ("Button "+string (Num)+" is right clicked.");
}
}

if ( Command == Button1 )
{
show_message ("Button1 is clicked.");
}



Example code:

is
Toolbar1 = API_Toolbar_Create (Win2,0); // Create the toolbar
API_Toolbar_AddSystemBitmaps (Toolbar1,0); // Use the system bitmaps
Button1 = API_Toolbar_AddButtonImage (Toolbar1,0,STD_FILENEW);
Separator1 = API_Toolbar_AddButton (Toolbar1,1,BTNS_SEP );
Button2 = API_Toolbar_AddButtonText (Toolbar1,2,"New");
API_Toolbar_SetButtonSize (Toolbar1,40,40); // Set the buttons to 40 x 40

Return to help index