Article ID: 174087
Article Last Modified on 2/24/2005
Index Key Picture ----- --- ------- 1 Bold ..\VB\Graphics\Bitmaps\Tlbr_w95\Bld.bmp 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
Index Key Image ----- --- ----- 1 Bold Bold 2 Italic Italic 3 Underline UnderlineNOTE: The Toolbar contains only these three buttons because this is the layout of the "default" toolbar. The Copy, Paste, and Cut buttons 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 As String, _
phkResult As Long) As Long
Const HKEY_CURRENT_USER = &H80000001
Private Sub Form_Load()
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 "Available Buttons" list
Toolbar1.Buttons.Add , "Copy", , , "Copy"
Toolbar1.Buttons.Add , "Paste", , , "Paste"
Toolbar1.Buttons.Add , "Cut", , , "Cut"
'Restore the toolbar settings
DoEvents
Toolbar1.RestoreToolbar "Test", "MyApp", "Toolbar1"
DoEvents
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
NOTE: If you are using Visual Basic version 6.0, change the following line
in the Form_GotFocus event:
Success = RegOpenKey(HKEY_CURRENT_USER, "MyApp", hKey)to:
Success = RegOpenKey(HKEY_CURRENT_USER, "Test\MyApp", hKey)
182943 : BUG: "Key" Argument of SaveToolBar & RestoreToolBar Doesn't Work
Keywords: kbhowto kbcontrol KB174087