AllAPI Network - The KPD-Team

Allapi Network

 API List

API Resources
 Tips & Tricks
 VB Tutorials
 Error Lookup
Misc Stuff
 VB examples
 VB Tools
 VB Links
 Top Downloads
This Site
 Search Engine
 Contact Form

Donate to

Creating Office 97 Toolbars

Internet Explorer 3.0 and Office 97 brought in a revolution in toolbars. The now extremely popular 'popup button' toolbars are taking over almost any new application which has toolbars - and I can see why. I mean, it's got style, a simple look and adds an attractive side to your application.  Visual Basic 5.0 didn't bring these controls in as a part of its new control set, but you can do it yourself with the old Common Controls Toolbar, and an API call.

1. Create a new project, and add the Common Controls ActiveX control to it.
2. Draw the Toolbar onto a form. Add your buttons.
3. Place the following into the General Declarations section:

    Private Declare Function FindWindowEx Lib "user32" _
    Alias "FindWindowExA" (ByVal hWndParent As Long, ByVal _
    hWndChildWindow As Long, ByVal lpClassName As String, _
    ByVal lpsWindowName As String) As Long

    Const TB_SETSTYLE = WM_USER + 56
    Const TB_GETSTYLE = WM_USER + 57

    Const WM_USER = &H400

    Const TBSTYLE_FLAT = &H800

4. Add this Sub to the General Declarations Section as well:

    Public Sub SetTBar97(TBar As Toolbar)
        Dim lTBarStyle As Long, lTBarHwnd As Long
        lTBarHwnd = FindWindowEx(TBar.hWnd, 0&, _
        "ToolbarWindow32", vbNullString)
        lTBarStyle = SendMessage(lTBarHwnd, TB_GETSTYLE, _
        0&, 0&)
        lTBarStyle = lTBarStyle Or TBSTYLE_FLAT
        SendMessage lTBarHwnd, TB_SETSTYLE, 0, lTBarStyle
    End Sub

5. Add a Module and add this to it:

    Declare Function SendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As _
    Long, ByVal wParam As Long, lParam As Any) As Long

6. You can make the Toolbars Office 97 Style with:

SetTBar97 Toolbar1

Toolbar1, of course, being your toolbar control's name.



Copyright © 1998-2007, The Team - Privacy statement
Did you find a bug on this page? Tell us!
This site is located at