MS's ToolBar is the most easily found toolbar control, simple and convenient, but its shortcomings are also obvious, style old-fashioned, with this era. In order to solve this problem, I specialize in a class. In fact, Toolbar provides a CustomDraw feature, MS is tied to Toolbar's framework, just Toolbar's model is handed over, very simple, you can use anything you want, use all the features of Toolbar, this Is it more convenient to do Toolbar than yourself? This function is of course triggering through the message mechanism, which is through the WM_NOTIFY message. The LPARAM parameter of this message is to point to an address of an NMHDR structure. Through the NMHDR structure, we can learn about the HWND of the message, determine the type of control, and What further determine the type of the entire structure is then obtained NMCUSTOMDRAW and NMTBCUSTOMDRAW structure, NMTBCUSTOMDRAW front is NMCUSTOMDRAW, and NMCUSTOMDRAW front is NMHDR, so a NMHDR, NMCUSTOMDRAW, NMCUSTOMDRAW are actually the same address lParam, just in front of the information required in accordance with Eventually determine the length of the entire structure.
WM_LBUTTONDOWN, WM_LBUTTONUP message should have nothing to do with this class, just a button with menu in Toolbar, I don't know how to get its Drap news, so I was forced to use the right to judge the right power. I don't know which one can change this. change.
The DrawToolBarbutton process is the core content of the button style. It can make the ideal Toolbar in this section.
'Test the code in the form: There is a Toolbar, it is preferable to have imagelist. Option ExplicitPrivate Sub Command1_Click () Dim i As Long With oTbr Randomize 'If .BackPicture = "" Then' .BackPicture = "e: /12.jpg" 'Else' .BackPicture = "" 'End If .BorderColor = vbBlue' only Borderstyle is more effective. BackColor = RND * (2 ^ 24) .TextColor = rND * (2 ^ 24) .TexThicolor = RND * (2 ^ 24) i = .borderstyle 1 if i> 4 Then i = 0 .BorderStyle = i 'in the range 0-4 End WithEnd SubPrivate Sub Command2_Click () If oTbr Is Nothing Then Set oTbr = New cToolbar With oTbr .BindToolBar Toolbar1.hWnd End With Command2.Caption = "cancel style" Command1.Enabled = True Else Set oTbr = Nothing Toolbar1.Refresh Command2.Caption = "load styles" Command1.Enabled = False End IfEnd SubPrivate Sub Form_Load () Command1.Caption = "randomly changed appearance" Command2.Caption = "load styles" Command2.Enabled = True Command1 .Enabled = falseend sub
Private Sub Form_Unload (Cancel As INTEGER) SETBR = Nothingend Sub ------------------------------------- -------------