Make A Flat Toolbar In VB5

Monday Nov 30th 1998 by Xiang Yue
Share:

Create a flat toolbar in VB5 using WinAPI

You just need to do as followings:

First: copy these code in your module


'--------------
'Const .....
'--------------------------
Public Const WM_USER = &H400
Public Const TB_SETSTYLE = WM_USER + 56
Public Const TB_GETSTYLE = WM_USER + 57
Public Const TBSTYLE_FLAT = &H800
Public Const TBSTYLE_TOOLTIPS = &H100
Public Const TBSTYLE_WRAPABLE = &H200
Public Const TBSTYLE_ALTDRAG = &H400
Public Const TBSTYLE_LIST = &H1000
Public Const TBSTYLE_CUSTOMERASE = &H2000

'--------------- 'API...... '--------------------- Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As Long) As Long Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA"_ (ByVal hWnd1 As Long, _ ByVal hWnd2 As Long, _ ByVal lpsz1 As String, _ ByVal lpsz2 As String) As Long

'------------------------------------------------------ 'A public sub in order to make a flat toolbar 'Enteries:tb(the name of your toolbar control) 'Return : no '----------------------------------------------------- Public Sub FlatBar(ByVal tb As Toolbar) Dim style As Long Dim hToolbar As Long Dim r As Long hToolbar = FindWindowEx(tb.hwnd, 0&, "ToolBarWindow32", vbNullString) style = SendMessageLong(hToolbar, TB_GETSTYLE, 0&, 0&) If style And TBSTYLE_FLAT Then style = style Xor TBSTYLE_FLAT Else: style = style Or TBSTYLE_FLAT End If r = SendMessageLong(hToolbar, TB_SETSTYLE, 0, style) tb.Refresh End Sub

Second: In your form put one Toolbar control(named MyTB) and one ImageList control,at the same time put some icons in Imagelist.now bind Imagelist with Toolbar get a comm Toolbar.

Third: In your form Load event call sub FlatBar() like this : Call FlatBar(MyTB)

Fourth: Now Run your project to see what happen in you toolbar. is it Cool ?

Posted On: 30-Nov-1998

Share:
Home
Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved