VB6 - Change your Toolbar Background (Color or Picture)

Các ví dụ nho nhỏ và những thứ linh tinh không thuộc nhóm nào
Post Reply
User avatar
truongphu
VIP
VIP
Posts: 4781
Joined: Sun 04/11/2007 10:57 am
Location: Cam Đức, Khánh hòa
Has thanked: 14 times
Been thanked: 525 times

VB6 - Change your Toolbar Background (Color or Picture)

Post by truongphu »

Tên chương trình: VB6 - Change your Toolbar Background (Color or Picture)
Ngôn ngữ lập trình: vb6
Tác giả: Jcis
Chức năng: VB6 - Change your Toolbar Background (Color or Picture)
Module

Code: Select all

Option Explicit 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 Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" ( _                ByVal hwnd As Long, ByVal nindex As Long, ByVal dwnewlong As Long) As Long Public Declare Function InvalidateRect Lib "user32" _                (ByVal hwnd As Long, lpRect As Long, ByVal bErase As Long) As Long Public Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long Public Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long Public Enum enuTBType    enuTB_FLAT = 1    enuTB_STANDARD = 2End Enum Private Const GCL_HBRBACKGROUND = (-10) Public Sub ChangeTBBack(TB As Object, PNewBack As Long, pType As enuTBType)Dim lTBWnd      As Long     Select Case pType                Case enuTB_FLAT     'FLAT Button Style Toolbar            DeleteObject SetClassLong(TB.hwnd, GCL_HBRBACKGROUND, PNewBack) 'Its Flat, Apply directly to TB Hwnd                Case enuTB_STANDARD 'STANDARD Button Style Toolbar            lTBWnd = FindWindowEx(TB.hwnd, 0, "msvb_lib_toolbar", vbNullString) 'Standard, find Hwnd first            DeleteObject SetClassLong(lTBWnd, GCL_HBRBACKGROUND, PNewBack)      'Set new Back    End SelectEnd Sub'=================================================================================================================' If you want to use Win Common Control 5 Toolbars, use "ToolbarWindow32" instead of "msvb_lib_toolbar"' Win Common Control 5 Toolbars can't be FLAT, they are always STANDARD, so use enuTB_STANDARD when you call this'================================================================================================================= 
Form

Code: Select all

Option Explicit Private Sub Form_Load()    ApplyChangesEnd Sub Private Sub ApplyChanges()    Dim LngNew As Long        'Use a picture with the FLAT TB (Toolbar1)    LngNew = CreatePatternBrush(Picture1.Picture.Handle) 'Creates the background from a Picture Handle    ChangeTBBack Toolbar1, LngNew, enuTB_FLAT        'Change Backcolor to STANDARD TB (Toolbar2)    LngNew = CreateSolidBrush(RGB(240, 120, 120))        'Creates the background from a Color (Long)    ChangeTBBack Toolbar2, LngNew, enuTB_STANDARD        'Refresh Screen to see changes    InvalidateRect 0&, 0&, FalseEnd Sub  
Attachments
Change Toolbar Background.zip
(15 KiB) Downloaded 717 times
o0o--truongphu--o0o

.........
Ghé thăm:
Chuyện Linh Tinh
User avatar
truongphu
VIP
VIP
Posts: 4781
Joined: Sun 04/11/2007 10:57 am
Location: Cam Đức, Khánh hòa
Has thanked: 14 times
Been thanked: 525 times

Re: VB6 - Change your Toolbar Background (Color or Picture)

Post by truongphu »

Cùng tác giả: Thêm 2 project sau
Change Toolbar Back.zip
(14.4 KiB) Downloaded 524 times
Attachments
Skinned MDIForm and MDIChild Toolbars.zip
(25.99 KiB) Downloaded 544 times
o0o--truongphu--o0o

.........
Ghé thăm:
Chuyện Linh Tinh
User avatar
truongphu
VIP
VIP
Posts: 4781
Joined: Sun 04/11/2007 10:57 am
Location: Cam Đức, Khánh hòa
Has thanked: 14 times
Been thanked: 525 times

Đổi màu Menu

Post by truongphu »

Tên chương trình: Đổi màu Menu
Ngôn ngữ lập trình: vb6
Tác giả: Sưu tầm
Chức năng: Đổi màu Menu

Code: Select all

Option ExplicitPrivate Const MIM_BACKGROUND As Long = &H2Private Const MIM_APPLYTOSUBMENUS As Long = &H80000000Private Type MENUINFOcbSize As LongfMask As LongdwStyle As LongcyMax As LonghbrBack As LongdwContextHelpID As LongdwMenuData As LongEnd Type Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As LongPrivate Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As LongPrivate Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As LongPrivate Declare Function SetMenuInfo Lib "user32" (ByVal hMenu As Long, mi As MENUINFO) As LongPrivate Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As LongPrivate Sub Command1_Click() Dim mi As MENUINFOWith mi.cbSize = Len(mi).fMask = MIM_BACKGROUND.hbrBack = CreateSolidBrush(vbYellow)SetMenuInfo GetMenu(Me.hWnd), mi  'main menu bar.fMask = MIM_BACKGROUND Or MIM_APPLYTOSUBMENUS.hbrBack = CreateSolidBrush(vbCyan)SetMenuInfo GetSubMenu(GetMenu(Me.hWnd), 0), mi 'this could a File menu perhapsEnd With DrawMenuBar Me.hWndEnd Sub 
Attachments
Doi màu Menu2.rar
(1.42 KiB) Downloaded 564 times
o0o--truongphu--o0o

.........
Ghé thăm:
Chuyện Linh Tinh
Post Reply

Return to “[VB] Mã nguồn linh tinh”