VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 把 VB 标准的工具栏变成平面式
发表评论(0)作者:, 平台:, 阅读:9923, 日期:2000-03-12
把 VB 标准的工具栏变成平面式

平面式的工具栏好象显得很酷!但 VB5 只提供了普通的凸起的工具栏。你是否想

把它变成平面的?这似乎

很不容易。但事实并非如此,试试:

BAS:

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 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

SUB:

Private Sub MakeFlat()

Dim style As Long

Dim hToolbar As Long

Dim r As Long

hToolbar = FindWindowEx(Toolbar1.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)

Toolbar1.Refresh

End Sub

注意:需要 4.70 或其以上版本的 comctl32.dll 支持。