HOWTO: Display Additional Buttons in Customize Toolbar DialogLast reviewed: September 26, 1997Article ID: Q174087 |
The information in this article applies to:
for Windows, version 5.0 32-bit only, for Windows, version 4.0
SUMMARYThe Toolbar control that is provided with the Microsoft Windows Common Controls (COMCTL32.OCX) can be customized by users. The Customize Toolbar method is displayed if either:
the Toolbar -or- By default, this dialog lists all of the buttons on the Toolbar in the "Toolbar Buttons" lists but lists only a Separator in the "Available Buttons" list. This article describes how you can display additional toolbar buttons in the "Available Buttons" list.
MORE INFORMATIONAll of the buttons in the Buttons collection of a Toolbar control appear in the Customize Toolbar dialog. Buttons that are currently showing on the Toolbar appear in the "Toolbar Buttons" list and Buttons that have been removed from the Toolbar through customization appear in the "Available Buttons" list. To add additional buttons to the "Available Buttons" list, create your default toolbar, use the SaveToolbar method to save this setting, add the additional buttons at run-time, and then use RestoreToolbar to restore the "default" toolbar settings.
Step-by-Step Example
2 Italic..\VB\Graphics\Bitmaps\Tlbr_w95\Itl.bmp 3 Underline..\VB\Graphics\Bitmaps\Tlbr_w95\Undrln.bmp 4 Copy..\VB\Graphics\Bitmaps\Tlbr_w95\Copy.bmp 5 Paste..\VB\Graphics\Bitmaps\Tlbr_w95\Paste.bmp 6 Cut..\VB\Graphics\Bitmaps\Tlbr_w95\Cut.bmp
layout of the "default" toolbar. The Copy, Paste, and Cutbuttons will be added at run-time so that they will appear in the"Additional Buttons" list.
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias_ "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey AsString, _ phkResult As Long) As Long Const HKEY_CURRENT_USER = &H80000001 Private Sub Form_GotFocus() Me.Show 'Check to see if the registry keys for the toolbar exists 'If not, then save the initial toolbar settings Success = RegOpenKey(HKEY_CURRENT_USER, "MyApp", hKey) If Success <> 0 Then Toolbar1.SaveToolbar "Test","MyApp", _ "Toolbar1" 'Add the toolbars you wish to see in the "AvailableButtons" list Toolbar1.Buttons.Add , "Copy", , , "Copy" Toolbar1.Buttons.Add , "Paste", , , "Paste" 'Restore the toolbar settings DoEvents Toolbar1.RestoreToolbar "Test", "MyApp", "Toolbar1" DoEvents bFormLoad = False End Sub Private Sub Form_Unload(Cancel As Integer) 'When the form unloads, save the toolbar settings 'to HKEY_CURRENT_USER\MyApp Toolbar1.SaveToolbar "Test", "MyApp", "Toolbar1" End Sub display the Customize Toolbar dialog. Notice that the Cut,Copy, and Paste toolbars appear in the Additional Buttons list. NOTE: The SaveToolbar and RestoreToolbar methods used in thisexample write and read the registry entryHKEY_CURRENT_USER\MyApp\Toolbar1. Keywords : vb432 VB4WIN vb5all vb5howto VBKBAX VBKBComp VBKBCtrl Version : WINDOWS:4.0 5.0 Platform : WINDOWS Issue type : kbhowto |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |