CRebar.cls
上传用户:davilee3
上传日期:2015-04-22
资源大小:986k
文件大小:17k
源码类别:

浏览器

开发平台:

Visual Basic

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "CRebar"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
  15. Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
  16. '2004-10-7
  17. '当系统颜色改变时可以随着改变(Sub UpdateSystemColor)
  18. '2004-05-21
  19. '增加了Sub ShowBand,可以设置显示或隐藏某band
  20. Option Explicit
  21. Public RebarWindow As Long
  22. Private RebarChildWin As Object
  23. Dim RebarBand As tagRebarBandInfo
  24. 'Dim a As Variant
  25. Private Type tagInitCommonControlsEx
  26.     lngSize As Long
  27.     lngICC As Long
  28. End Type
  29. Dim i As Integer
  30. Public Enum BandPosition
  31. AddNewRow = 1
  32. AddToEnd = 2
  33. End Enum
  34. Private Const HWND_TOPMOST = -1
  35. Private Const SW_HIDE = 0
  36. Private Const SW_SHOWNORMAL = 1
  37. Private Const GW_CHILD = 5
  38. Private Const GW_HWNDNEXT = 2
  39. Private Const SWP_NOSIZE = &H1
  40. Private Const SWP_NOMOVE = &H2
  41. Private Const SWP_NOREDRAW = &H8
  42. Private Const SWP_SHOWWINDOW = &H40
  43. Private RebarPic As Object
  44. Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wcmd As Long) As Long
  45. Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
  46. Private Declare Function UpdateWindow Lib "user32" (ByVal hwnd As Long) As Long
  47. Private Declare Function InitCommonControlsEx Lib "comctl32.dll" (iccex As tagInitCommonControlsEx) As Boolean
  48. Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
  49. Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
  50. Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
  51. Private Declare Function CreateWindowEX Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hwndParent As Long, ByVal HMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
  52. Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
  53. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  54. Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
  55. Private Declare Function SendTBMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, _
  56. ByVal lParam As Any) As Long
  57. Private 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
  58. Private Const WM_USER = &H400
  59. Dim b As Variant
  60. ''Toolbar Const
  61. 'Private Const TBSTYLE_TRANSPARENT = &H8000 'Haven't gotton this one to work with regular toolbars yet.
  62. 'Private Const TBSTYLE_FLAT = &H800
  63. 'Private Const TB_SETSTYLE = (WM_USER + 56)
  64. 'Private Const TB_GETSTYLE = (WM_USER + 57)
  65. 'Private Const TBSTYLE_LIST = &H1000
  66. Private Type RECT
  67.         Left As Long
  68.         Top As Long
  69.         Right As Long
  70.         Bottom As Long
  71. End Type
  72.  
  73. 'System Color Constants
  74. Private Const COLOR_BTNFACE = 15
  75. Private Const COLOR_BTNTEXT = 18
  76. Private Const REBARCLASSNAME = "ReBarWindow32"
  77. Private Const RBN_FIRST = 0 - 831
  78. Private Const RBN_LAST = 0 - 859
  79. Private Const RBIM_IMAGELIST = &H1
  80. Private Const ICC_COOL_CLASSES = &H400
  81. 'Rebar Styles
  82. Private Const RBS_AUTOSIZE = &H2000
  83. Private Const RBS_VERTICALGRIPPER = &H4000 '  // this always has the vertical gripper (default for horizontal mode)
  84. Private Const RBS_TOOLTIPS = &H100
  85. Private Const RBS_VARHEIGHT = &H200
  86. Private Const RBS_DBLCLKTOGGLE As Long = &H8000
  87. Private Const RBS_BANDBORDERS = &H400
  88. Private Const RBBS_VARIABLEHEIGHT = &H40
  89. Private Const RBS_FIXEDORDER = &H800
  90. Private Const RBBS_GRIPPERALWAYS = &H80      ' always show the gripper
  91. Private Const RBBS_BREAK = &H1               ' break to new line
  92. Private Const RBBS_FIXEDSIZE = &H2           ' band can't be sized
  93. Private Const RBBS_CHILDEDGE = &H4           ' edge around top & bottom of child window
  94. Private Const RBBS_HIDDEN = &H8              ' don't show
  95. Private Const RBBS_NOVERT = &H10             ' don't show when vertical
  96. Private Const RBBS_FIXEDBMP = &H20           ' bitmap doesn't move during band resize
  97. Private Const RBBS_NOGRIPPER As Long = &H100
  98. Private Const RBBS_USECHEVRON As Long = &H200
  99. Private Const RBBIM_STYLE = &H1
  100. Private Const RBBIM_COLORS = &H2
  101. Private Const RBBIM_TEXT = &H4
  102. Private Const RBBIM_IMAGE = &H8
  103. Private Const RBBIM_CHILD = &H10
  104. Private Const RBBIM_CHILDSIZE = &H20
  105. Private Const RBBIM_SIZE = &H40
  106. Private Const RBBIM_BACKGROUND = &H80
  107. Private Const RBBIM_ID = &H100
  108. Private Const RBBIM_HEADERSIZE As Long = &H800
  109. Private Const RB_BEGINDRAG = (WM_USER + 24)
  110. Private Const RB_ENDDRAG = (WM_USER + 25)
  111. Private Const RB_DRAGMOVE = (WM_USER + 26)
  112. Private Const RB_HITTEST = (WM_USER + 8)
  113. Private Const RB_INSERTBANDA = (WM_USER + 1)
  114. Private Const RB_DELETEBAND = (WM_USER + 2)
  115. Private Const RB_GETBARINFO = (WM_USER + 3)
  116. Private Const RB_SETBARINFO = (WM_USER + 4)
  117. Private Const RB_GETBANDINFO = (WM_USER + 5)
  118. Private Const RB_SETBANDINFOA = (WM_USER + 6)
  119. Private Const RB_SETPARENT = (WM_USER + 7)
  120. Private Const RB_INSERTBANDW = (WM_USER + 10)
  121. Private Const RB_SETBANDINFOW = (WM_USER + 11)
  122. Private Const RB_GETBANDCOUNT = (WM_USER + 12)
  123. Private Const RB_GETROWCOUNT = (WM_USER + 13)
  124. Private Const RB_GETROWHEIGHT = (WM_USER + 14)
  125. Private Const RB_SETBKCOLOR = (WM_USER + 19)
  126. Private Const RB_GETBKCOLOR = (WM_USER + 20)
  127. Private Const RB_SETTEXTCOLOR = (WM_USER + 21)
  128. Private Const RB_GETTEXTCOLOR = (WM_USER + 22)
  129. Private Const RBHT_NOWHERE = &H1
  130. Private Const RBHT_CAPTION = &H2
  131. Private Const RBHT_CLIENT = &H3
  132. Private Const RBHT_GRABBER = &H4
  133. Private Const GWL_HWNDPARENT = (-8)
  134. Private Const GWL_STYLE = (-16)
  135. Private Const RB_INSERTBAND = RB_INSERTBANDA
  136. Private Const RB_SETBANDINFO = RB_SETBANDINFOA
  137. Private Const RBN_HEIGHTCHANGE = (RBN_FIRST - 0)
  138. Private Const RB_SHOWBAND As Long = (WM_USER + 35)
  139. Private Const RB_IDTOINDEX As Long = (WM_USER + 16)
  140. 'CreateWindowEx Constants
  141. Private Const WS_EX_TOOLWINDOW As Long = &H80&
  142. Private Const WS_BORDER = &H800000
  143. Private Const WS_CLIPCHILDREN = &H2000000
  144. Private Const WS_CLIPSIBLINGS = &H4000000
  145. Private Const WS_VISIBLE = &H10000000
  146. Private Const WS_CHILD = &H40000000
  147. Private Const CCS_NORESIZE = &H4
  148. Private Const CCS_NOPARENTALIGN = &H8
  149. Private Const CCS_NODIVIDER = &H40
  150. Private Const CCS_VERT = &H80
  151. 'Private Type tagRebarInfo
  152. '    cbSize As Integer
  153. '    fMask As Integer
  154. '    himl As Long
  155. 'End Type
  156.  Private Type tagRebarBandInfo
  157.     cbSize As Long
  158.     fMask As Long
  159.     fStyle As Long
  160.     clrFore As Long
  161.     clrBack As Long
  162.     lpText As String
  163.     cch As Long
  164.     iImage As Long
  165.     hWndChild As Long
  166.     cxMinChild As Long
  167.     cyMinChild As Long
  168.     cx As Long
  169.     hbmBack As Long
  170.     wID As Long
  171.     
  172.     '#if (_WIN32_IE >= 0x0400)
  173.         cyChild As Long
  174.         cyMaxChild As Long
  175.         cyIntegral As Long
  176.         cxIdeal As Long
  177.         lParam As Long
  178.         cxHeader As Long
  179.     '#End If
  180. End Type
  181.  
  182. Private RebarhWnd As Long
  183. Private RebarParent As Object
  184. Public Sub SizeBand(ByVal index As Long, ByVal cxMin As Long, ByVal cyMin As Long, ByVal cx As Long, Optional ByCommand As Boolean = False)
  185. Dim tBand As tagRebarBandInfo
  186. Dim iBand As Long
  187. If ByCommand Then
  188.     iBand = SendMessage(RebarhWnd, RB_IDTOINDEX, index, 0&)
  189. Else
  190.     iBand = index
  191. End If
  192. With tBand
  193.     .cbSize = Len(tBand)
  194.     .fMask = RBBIM_CHILDSIZE Or RBBIM_SIZE 'Or RBBIM_ID
  195.     .cx = cx
  196.     .cxMinChild = cxMin
  197.     .cyMinChild = cyMin
  198. End With
  199. SendMessage RebarhWnd, RB_SETBANDINFO, iBand, tBand
  200. End Sub
  201.  
  202.  
  203. 'Sub TBMakeFlat(Tb As Object, Optional TBList As Boolean)
  204. '
  205. '   Dim Style As Long
  206. '   Dim lRet As Long
  207. '   Dim ToolbarHandle As Long
  208. '
  209. '
  210. '   ToolbarHandle = FindWindowEx(Tb.hwnd, 0&, "ToolbarWindow32", vbNullString)
  211. '
  212. '   Style = SendTBMessage(ToolbarHandle, TB_GETSTYLE, 0&, 0&)
  213. '
  214. '   If TBList = True Then
  215. '   Style = Style Or TBSTYLE_FLAT Or TBSTYLE_TRANSPARENT Or CCS_NODIVIDER Or TBSTYLE_LIST
  216. '   Else
  217. '   Style = Style Or TBSTYLE_FLAT Or TBSTYLE_TRANSPARENT Or CCS_NODIVIDER
  218. '   End If
  219. '
  220. '   lRet = SendTBMessage(ToolbarHandle, TB_SETSTYLE, 0, Style)
  221. '
  222. '   Tb.Refresh
  223. '
  224. 'End Sub
  225. Public Sub AddBands(BandText As String, BandName As Integer, _
  226. ChildWin As Variant, NewRow As BandPosition, Optional mWidth As Variant)
  227.       
  228. On Error Resume Next
  229. 'Set structure
  230. RebarBand.cbSize = LenB(RebarBand)
  231. 'Add Mask for all possibilities
  232. RebarBand.fMask = RBBIM_COLORS Or RBBIM_IMAGE Or RBBIM_BACKGROUND Or RBBS_FIXEDBMP Or RBBIM_CHILD Or RBBIM_CHILDSIZE Or _
  233. RBBIM_ID Or RBBIM_STYLE Or RBBIM_TEXT Or RBBS_BREAK Or RBBS_USECHEVRON
  234. 'Set RebarBands Colors
  235. RebarBand.clrFore = GetSysColor(COLOR_BTNTEXT)
  236. RebarBand.clrBack = GetSysColor(COLOR_BTNFACE)
  237. 'If NewRow = AddNewRow Then
  238. 'RebarBand.fStyle = RBBS_FIXEDBMP Or RBBS_CHILDEDGE Or RBS_VARHEIGHT Or RBBS_GRIPPERALWAYS
  239. 'Else
  240. 'RebarBand.fStyle = RBBS_FIXEDBMP Or RBBS_CHILDEDGE Or RBS_VARHEIGHT Or RBBS_BREAK Or RBBS_GRIPPERALWAYS
  241. 'End If
  242. If NewRow = AddToEnd Then
  243. RebarBand.fStyle = RBBS_FIXEDBMP Or RBS_VARHEIGHT Or RBBS_GRIPPERALWAYS
  244. Else
  245. RebarBand.fStyle = RBBS_FIXEDBMP Or RBS_VARHEIGHT Or RBBS_BREAK Or RBBS_GRIPPERALWAYS
  246. End If
  247. 'Add Band Text if any
  248. RebarBand.lpText = BandText
  249.  
  250. 'Set BackGround Picture
  251. 'RebarBand.hbmBack = RebarPic.Picture
  252.  
  253. If ChildWin <> "" Then
  254. RebarBand.hWndChild = ChildWin
  255. Set RebarChildWin = ChildWin
  256. End If
  257. RebarBand.cxMinChild = ChildWin.Width / Screen.TwipsPerPixelX
  258. If mWidth Then RebarBand.cxMinChild = mWidth * Screen.TwipsPerPixelX
  259. 'Band height
  260. Dim ChildRect As RECT
  261. Call GetWindowRect(ChildWin, ChildRect)
  262. RebarBand.cyMinChild = (ChildRect.Bottom - ChildRect.Top)
  263. 'SetMin Height
  264. RebarBand.cx = 10
  265.  
  266. RebarBand.wID = BandName
  267.  
  268. Call SendMessage(RebarhWnd, RB_INSERTBAND, -1, RebarBand) '-1 = add to end
  269. Call UpdateWindow(RebarhWnd)
  270.  
  271. End Sub
  272. 'Public Function GetBandId(ID As Integer)
  273. 'If IsNumeric(ID) = False Then Exit Function
  274. '
  275. 'Dim RebarBand As tagRebarBandInfo
  276. 'RebarBand.cbSize = LenB(RebarBand)
  277. '
  278. ''Add Mask for all possibilities
  279. 'RebarBand.fMask = RBBIM_COLORS Or RBBIM_IMAGE Or RBBIM_BACKGROUND Or RBBS_FIXEDBMP Or RBBIM_CHILD Or RBBIM_CHILDSIZE Or _
  280. 'RBBIM_ID Or RBBIM_STYLE Or RBBIM_TEXT Or RBBS_BREAK Or RBS_FIXEDORDER Or RBBS_FIXEDSIZE
  281. ''Set RebarBands Colors
  282. 'Dim xReturn As Long
  283. 'xReturn = SendMessage(RebarhWnd, RB_GETBANDINFO, ID, RebarBand)
  284. 'GetBandId = RebarBand.wID
  285. '
  286. 'End Function
  287. 'Public Sub SetBandColors()
  288. '
  289. ''This procedure is used to set the band colors in case the system color changes
  290. '
  291. 'Dim RebarBand As tagRebarBandInfo
  292. 'RebarBand.cbSize = LenB(RebarBand)
  293. '
  294. ''Add Mask for all possibilities
  295. 'RebarBand.fMask = RBBIM_COLORS Or RBBIM_IMAGE Or RBBIM_BACKGROUND Or RBBS_FIXEDBMP Or RBBIM_CHILD Or RBBIM_CHILDSIZE Or _
  296. 'RBBIM_ID Or RBBIM_STYLE Or RBBIM_TEXT Or RBBS_BREAK Or RBS_FIXEDORDER Or RBBS_FIXEDSIZE
  297. ''Set RebarBands Colors
  298. '
  299. 'Dim xReturn As Long
  300. 'Dim xCount As Integer
  301. 'xCount = SendMessage(RebarhWnd, RB_GETBANDCOUNT, 0, 0)
  302. '
  303. 'For xCount = 0 To xCount - 1
  304. 'xReturn = SendMessage(RebarhWnd, RB_GETBANDINFO, xCount, RebarBand)
  305. '
  306. 'RebarBand.clrFore = GetSysColor(COLOR_BTNTEXT)
  307. 'RebarBand.clrBack = GetSysColor(COLOR_BTNFACE)
  308. '
  309. 'xReturn = SendMessage(RebarhWnd, RB_SETBANDINFO, xCount, RebarBand)
  310. 'Next
  311. '
  312. 'End Sub
  313. Public Sub DestroyRebar()
  314. On Error Resume Next
  315. If RebarhWnd <> 0 Then
  316.     Call ShowWindow(RebarhWnd, SW_HIDE)
  317.     
  318.     Dim bandCount As Integer, i As Integer
  319.     
  320.     'Get Number of bands
  321.     bandCount = SendMessage(RebarhWnd, RB_GETBANDCOUNT, 0, 0)
  322.     For i = 0 To bandCount - 1
  323.         RemoveBands 0
  324.     Next
  325.  
  326.    Call DestroyWindow(RebarhWnd)
  327.    RebarhWnd = 0
  328. End If
  329. End Sub
  330. 'Public Function GetRebarWindow()
  331. 'GetRebarWindow = RebarhWnd
  332. 'End Function
  333. Public Sub RemoveBands(Optional BandPosition As Integer = 0)
  334. On Error Resume Next
  335. Dim tRBI As tagRebarBandInfo
  336. Dim hChild As Long
  337. With tRBI
  338.     .cbSize = Len(tRBI)
  339.     .fMask = RBBIM_CHILD
  340. End With
  341. Call SendMessage(RebarhWnd, RB_GETBANDINFO, BandPosition, tRBI)
  342. hChild = tRBI.hWndChild
  343. tRBI.hWndChild = 0&
  344. tRBI.fMask = RBBIM_CHILD
  345. Call SendMessage(RebarhWnd, RB_SETBANDINFO, BandPosition, tRBI)
  346. SetParent hChild, Parent.hwnd
  347. Call SendMessage(RebarhWnd, RB_DELETEBAND, BandPosition, 0)
  348. End Sub
  349.  
  350.  
  351. Public Sub Resize(frm As Object)
  352.  On Error Resume Next
  353.  Call MoveWindow(RebarhWnd, 0, 0, frm.Width / Screen.TwipsPerPixelX - 8, 0, True)
  354.  Call UpdateWindow(RebarhWnd)
  355. End Sub
  356.  
  357.  
  358.  
  359. Public Sub Move(Left As Long, Top As Long, Width As Long, Height As Long)
  360. On Error Resume Next
  361.     If hwnd <> 0 Then
  362.         Call MoveWindow(hwnd, Left, Top, Width, Height, True)
  363.     End If
  364.    
  365. End Sub
  366. Public Property Get hwnd() As Long
  367.     hwnd = RebarhWnd
  368.     RebarWindow = RebarhWnd
  369. End Property
  370. Public Function Create()
  371. On Error Resume Next
  372. Dim tStyle&
  373.     If (Parent Is Nothing) Or RebarhWnd <> 0 Then
  374.        Create = False
  375.        Exit Function
  376.     End If
  377.     
  378.      
  379.     'RBS_AUTOSIZE Or
  380.     
  381.     tStyle = WS_VISIBLE Or WS_BORDER Or WS_CHILD Or _
  382.         WS_CLIPCHILDREN Or WS_CLIPSIBLINGS Or _
  383.         RBS_VARHEIGHT Or RBS_BANDBORDERS Or _
  384.         RBS_VERTICALGRIPPER Or RBBS_VARIABLEHEIGHT Or _
  385.         CCS_NOPARENTALIGN Or CCS_NODIVIDER
  386.     
  387. '    tStyle = WS_VISIBLE Or WS_BORDER Or WS_CHILD Or _
  388.         RBS_VARHEIGHT Or RBS_BANDBORDERS Or RBS_DBLCLKTOGGLE Or _
  389.         CCS_NODIVIDER Or _
  390.          CCS_NOPARENTALIGN Or _
  391.         WS_CLIPCHILDREN Or WS_CLIPSIBLINGS
  392.     
  393.     RebarhWnd = CreateWindowEX(WS_EX_TOOLWINDOW, "ReBarWindow32", "", _
  394.     tStyle, 0, 0, Parent.Width, 60, _
  395.     Parent.hwnd, 0&, App.hInstance, 0&)
  396.   
  397.      
  398.     Call Move(CLng(0), CLng(0), CLng(Parent.Width), CLng(60))
  399.     Call ShowWindow(RebarhWnd, SW_SHOWNORMAL)
  400.     'Set Parent to receive messages
  401.     Call SetParent(RebarhWnd, Parent.hwnd)
  402.     Create = (RebarhWnd <> 0)
  403.       
  404.   
  405. End Function
  406. Public Property Set Parent(frm As Object)
  407.     Set RebarParent = frm
  408. End Property
  409. Public Property Get Parent() As Object
  410.     Set Parent = RebarParent
  411. End Property
  412.  
  413. 'Public Property Set ImageForRebar(Img As Object)
  414. 'On Error Resume Next
  415. 'Set RebarPic = Img
  416. 'End Property
  417.  
  418.  
  419. Private Sub Class_Initialize()
  420.     Dim iccex As tagInitCommonControlsEx
  421.     With iccex
  422.         .lngSize = LenB(iccex)
  423.         .lngICC = ICC_COOL_CLASSES
  424.     End With
  425.     Call InitCommonControlsEx(iccex)
  426.     RebarhWnd = 0
  427. End Sub
  428. 'Public Sub SetMainParent(Obj As Object)
  429. '  Call SendMessage(RebarhWnd, RB_SETPARENT, Obj.hwnd, 0)
  430. 'End Sub
  431.  
  432. Private Sub Class_Terminate()
  433. 'Call DestroyRebar
  434. 'Place this in your form Unload event
  435. 'YourDimName.DestroyRebar
  436. End Sub
  437. Public Function GetHeight()
  438. Dim tRowCount As Long
  439. Dim tRowHeight As Long
  440. Dim a As Long
  441. tRowCount = SendMessage(RebarhWnd, RB_GETROWCOUNT, 0, 0)
  442. a = 0
  443. For i = 0 To tRowCount - 1
  444.   tRowHeight = SendMessage(RebarhWnd, RB_GETROWHEIGHT, i, 0)
  445.   a = a + tRowHeight
  446. Next
  447. GetHeight = a '+ 2 * (tRowCount + 1)
  448. End Function
  449. Private Sub LockBand(Locked As Boolean, index As Long)
  450. Dim tBand As tagRebarBandInfo
  451. With tBand
  452.     .cbSize = Len(tBand)
  453.     .fMask = RBBIM_STYLE + RBBIM_HEADERSIZE + RBBIM_TEXT
  454.     Dim tOff As Long
  455.     SendMessage RebarhWnd, RB_GETBANDINFO, index, tBand
  456.     
  457.     If .cch > 1 Then
  458.         tOff = 6
  459.     Else
  460.         tOff = 12
  461.     End If
  462.     If Locked Then
  463.         .fStyle = .fStyle Or RBBS_NOGRIPPER
  464.         .cxHeader = .cxHeader - tOff
  465.         
  466.       Else
  467.         .fStyle = .fStyle And (Not RBBS_NOGRIPPER)
  468.         .cxHeader = .cxHeader + tOff
  469.     End If
  470.     .fMask = RBBIM_STYLE + RBBIM_HEADERSIZE
  471.     SendMessage RebarhWnd, RB_SETBANDINFO, index, tBand
  472. End With
  473. End Sub
  474. Public Sub LockBands(Locked As Boolean)
  475. Dim bandCount As Long
  476. Dim i As Long
  477. bandCount = SendMessage(RebarhWnd, RB_GETBANDCOUNT, 0, 0)
  478. For i = 0 To bandCount - 1
  479.     LockBand Locked, i
  480. Next
  481. End Sub
  482. Public Sub ShowBand(idBand As Long, fShow As Boolean)
  483. Dim tBand As tagRebarBandInfo
  484. Dim iBand As Long
  485. iBand = SendMessage(RebarhWnd, RB_IDTOINDEX, idBand, 0&)
  486. With tBand
  487.     .cbSize = Len(tBand)
  488.     .fMask = RBBIM_STYLE
  489.     
  490.     If fShow Then
  491.         .fStyle = .fStyle Or RBBS_HIDDEN
  492.         .fStyle = .fStyle Xor RBBS_HIDDEN
  493.     Else
  494.         .fStyle = .fStyle Or RBBS_HIDDEN
  495.     End If
  496. End With
  497. SendMessage RebarhWnd, RB_SETBANDINFO, iBand, tBand
  498. End Sub
  499. '更新系统颜色,band 的背景色与文字颜色
  500. Public Sub UpdateSystemColor()
  501. Dim tBand As tagRebarBandInfo
  502. Dim bandCount As Long
  503. Dim i As Long
  504. With tBand
  505.     .cbSize = Len(tBand)
  506.     .fMask = RBBIM_COLORS
  507.     .clrFore = GetSysColor(COLOR_BTNTEXT)
  508.     .clrBack = GetSysColor(COLOR_BTNFACE)
  509. End With
  510. bandCount = SendMessage(RebarhWnd, RB_GETBANDCOUNT, 0, 0)
  511. For i = 0 To bandCount - 1
  512.     SendMessage RebarhWnd, RB_SETBANDINFO, i, tBand
  513. Next i
  514. End Sub