Its characteristic is, no matter what we in the main form several combox custom painting, the inside of the each combox drop-down box options are all identical,
Now I think: two or more combox custom painting, the drop-down box inside the different content, how to modify the program code?
To thank ~! Below are links to sites of class module code:
VERSION 1.0 CLASS
The BEGIN
MultiUse=1 'True
Persistable=0 'NotPersistable
DataBindingBehavior=0 'vbNone
DataSourceBehavior=0 'vbNone
MTSTransactionMode=0 'NotAnMTSObject
END
The Attribute VB_Name="ColorCombox"
The Attribute VB_GlobalNameSpace=False
The Attribute VB_Creatable=True
The Attribute VB_PredeclaredId=False
The Attribute VB_Exposed=False
'the Download by http://www.NewXing.com
Option Explicit
Private Type VasmColorComBoxConst
ColorHDC As Long
ColorName As String
ColorRGB As Long
End Type
Private Type ThisClassSet
DefaultColor (0 To 17) As VasmColorComBoxConst
N_hWnd As Long
N_DefaultProc As Long
N_CID As Long
N_hBurshNor As Long
N_hBurshSel As Long
End Type
Dim PG As ThisClassSet
Dim LinkProc () As Long
The Event ItemClick (ByVal RGBColor As Long)
Private Sub MsgHook (Result As Long, ByVal cHwnd As Long, ByVal Message As Long, ByVal wParam As Long, ByVal lParam As Long)
Dim Dit As DRAWITEMSTRUCT
Dim As Long I
Dim txtColor As Long
Dim hBrush As Long
Dim Rct As the RECT
If (Message=WM_DRAWITEM) And (wParam=PG. N_CID) Then
The CopyMemory Dit, ByVal lParam& , LenB (Dit)
If Dit. ItemID=1 Then the Exit Sub
I=((Dit) rcItem) bottom - Dit. RcItem. Top - 12) \ 2) + Dit. RcItem. Top
Select Case Dit. The itemState
Case 1, 16, 17, 4113: hBrush=PG. N_hBurshSel: txtColor=GetSysColor (COLOR_HIGHLIGHTTEXT)
Case the Else: hBrush=PG. N_hBurshNor: txtColor=0
End the Select
'the Debug. Print Dit. ItemID, Dit itemState, Timer
SetBkMode Dit. HDC, 0 & amp;
FillRect Dit. HDC, Dit rcItem, hBrush
BitBlt Dit. HDC, Dit. RcItem. Left + 2, I, 25, 12, PG. DefaultColor (Dit) itemID). ColorHDC, 0, 0, SRCCOPY
Dit. RcItem. Left=Dit. RcItem. Left + 30
SetTextColor Dit. HDC, txtColor&
DrawText Dit. HDC, PG. DefaultColor (Dit) itemID). ColorName, 1 & amp; , Dit. RcItem, DT_SINGLELINE Or DT_VCENTER
The Exit Sub
End the If
Result=CallWindowProc (ByVal PG. N_DefaultProc & amp; , ByVal cHwnd, ByVal Message, ByVal wParam& , ByVal lParam&)
If the Message=WM_COMMAND And lParam=PG. N_hWnd Then
I=ItemSelected
Dim ps As POINTS
CopyMemory ps, wParam& , 4 & amp;
If ps. Y=CBN_SELCHANGE Then
If I=1 Then
PG. DefaultColor (1). ColorRGB=UserGetColor (PG. N_hWnd, PG. DefaultColor (1) ColorRGB)
DrawColorLabel PG. DefaultColor (1). ColorHDC, PG. DefaultColor (1) ColorRGB
UpdateWindow cHwnd
End the If
RaiseEvent ItemClick (PG. DefaultColor (I) ColorRGB)
End the If
End the If
End Sub
The Function CreateColorComboBox (hWndParent As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, Optional ByVal cID As Long) As Long
'CBS_OWNERDRAWVARIABLE Or
Dim cHwnd As Long
CHwnd=CreateWindowEx (0 & amp; , "ComboBox vbNullString WS_CHILD Or WS_TABSTOP Or WS_VISIBLE Or WS_VSCROLL Or CBS_OWNERDRAWFIXED Or CBS_DROPDOWNLIST Or CBS_HASSTRINGS Or CBS_AUTOHSCROLL, X1, Y1, X2, 180 & amp; , hWndParent, cID& , App. HInstance, ByVal 0 & amp;)
If cHwnd Then
SendMessage cHwnd WM_SETFONT, ByVal SendMessage (hWndParent WM_GETFONT, ByVal 0 & amp; , ByVal 0 & amp;) , ByVal 0 & amp;
Dim As Long I
For I=17 Step 1 To 0
SendMessageStr cHwnd CB_ADDSTRING, ByVal 0 & amp; , PG. DefaultColor (I). The ColorName
Next
PG. N_CID=cID
PG. N_hWnd=cHwnd
PG. N_DefaultProc=SetWindowLong (hWndParent, ByVal GWL_WNDPROC, ByVal GetWndProcAddress (11))
ColorSelected=PG. DefaultColor (1). ColorRGB
End the If
End the Function
Public Property Get ItemSelected () As Long
ItemSelected=SendMessage (PG) n_hWnd, ByVal CB_GETCURSEL, ByVal 0 & amp; , ByVal 0 & amp;)
End Property
Public Property Let ItemSelected (ByVal vNewValue As Long)
SendMessage PG n_hWnd, ByVal CB_SETCURSEL, ByVal vNewValue& , ByVal 0 & amp;
End Property
Public Property Get ColorSelected () As Long
Dim As Long I
I=SendMessage (PG. N_hWnd, ByVal CB_GETCURSEL, ByVal 0 & amp; , ByVal 0 & amp;)
ColorSelected=PG. DefaultColor (I). ColorRGB
End Property
Public Property Let ColorSelected (ByVal vNewValue As Long)
Dim As Long I
For I=17 Step 1 To 0
If I & lt;> 1 Then the If PG. DefaultColor (I) ColorRGB=vNewValue Then GoTo l1
Next
I=1
L1:
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull