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.
Declare Function GetWindowLong Lib "user32" _ Alias "GetWindowLongA" (ByVal hwnd As Long, _ ByVal nIndex As Long) As Long Declare Function SetWindowLong Lib "user32" _ Alias "SetWindowLongA" (ByVal hwnd As Long, _ ByVal nIndex As Long, ByVal dwNewLong As Long) As Long 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 Public Const GWL_STYLE = &HFFF0 Public Const TBSTYLE_FLAT = &H800 Public Sub TBar97(TBar As Toolbar) Dim lTBarStyle As Long, lTBarHwnd As Long If Not TypeOf TBar Is Toolbar Then Exit Sub lTBarHwnd = FindWindowEx(TBar.hwnd, 0&, "ToolbarWindow32", vbNullString) lTBarStyle = GetWindowLong(lTBarHwnd, GWL_STYLE) lTBarStyle = lTBarStyle Or TBSTYLE_FLAT lTBarStyle = SetWindowLong(lTBarHwnd, GWL_STYLE, lTBarStyle) TBar.Refresh End Sub
Now, in the Form's load event, call TBar97 to make your ToolBar into a CoolBar!
TBar97 ToolBar1
Thanks a lot to Alex Shulgin for this improved tip. However, this tip will only work for VB4 and VB5 toolbars. If you want the same effect in VB6, use the toolbar's style property, and set it to tbrFlat.