Formunuza 1 adet combobox ekleyin ve daha sonra alttaki kodlari projenize ekleyip calistirin. Benim hosuma gitti sizle paylasmak istedim. Formunuzun icine yazacaginiz kod Option Explicit Private Sub Form_Load Dim iIndex As Integer For iIndex = 0 To 15 Combo1. AddItem "Color " & iIndex Combo1. itemData(Combo1. NewIndex) = QBColor Next Combo1. ListIndex = 0 'Subclass the "Form", to Capture the Combobox Notification Messages SubClassForm hWnd End Sub Private Sub Form_Unload 'Release the SubClassing, Very Import to Prevent Crashing! RemoveSubClassing hWnd End Sub Ekleyeceginiz Modul Option Explicit Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Type DRAWITEMSTRUCT CtlType As Long CtlID As Long itemID As Long itemAction As Long itemState As Long hwndItem As Long hdc As Long rcItem As RECT itemData As Long End Type Private Type CWPSTRUCT lParam As Long wParam As Long message As Long hWnd As Long End Type Private Type CREATESTRUCT lpCreateParams As Long hInstance As Long hMenu As Long hWndParent As Long cy As Long cx As Long y As Long x As Long style As Long 'These next 2 are Normaly string, but need to be a fixed length 'so we know how long they are when using CopyMemory, 'We're only interested in the Style property anyway. lpszName As Long lpszClass As Long ExStyle As Long End Type Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" As Long Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" As Long Private Declare Function SetBkColor Lib "gdi32" As Long Private Declare Function SetTextColor Lib "gdi32" As Long Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" As Long Private Declare Function GetSysColor Lib "user32" As Long Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" As Long Private Declare Function FillRect Lib "user32" As Long Private Declare Function GetBkColor Lib "gdi32" As Long Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" As Long Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" As Long Private Declare Function UnhookWindowsHookEx Lib "user32" As Long Private Declare Function CallNextHookEx Lib "user32" As Long Private Declare Function CreateSolidBrush Lib "gdi32" As Long Private Const WH_CALLWNDPROC = 4 Private Const CBS_OWNERDRAWVARIABLE = &H20& Private Const CB_GETLBTEXT = &H148 Private Const CB_SETITEMHEIGHT = &H153 Private Const COLOR_HIGHLIGHT = 13 Private Const COLOR_HIGHLIGHTTEXT = 14 Private Const COLOR_WINDOW = 5 Private Const COLOR_WINDOWTEXT = 8 Private Const GWL_WNDPROC = (-4) Private Const GWL_STYLE = (-16) Private Const ODS_SELECTED = &H1 Private Const ODT_COMBOBOX = 3 Private Const WM_CREATE = &H1 Private Const WM_DRAWITEM = &H2B Private lPrevWndProc As Long Private lHook As Long Private lSubCombo As Long Sub Main 'The Combobox is a little more tricky to manipulate than a Listbox 'So we need to do a little extra work to make it an "Owner Drawn" Control. lHook = SetWindowsHookEx Form1. Show 'Once the Control. etc are Drawn, we can release the Hook Call UnhookWindowsHookEx End Sub Public Sub SubClassForm lPrevWndProc = SetWindowLong End Sub Public Sub RemoveSubClassing Call SetWindowLong End Sub Public Function SubClassedForm As Long Dim tItem As DRAWITEMSTRUCT Dim sItem As String Dim lBackBrush As Long If Msg = WM_DRAWITEM Then 'This function only passes the Address of the DrawItem Structure, so we need to 'use the CopyMemory API to get a Copy into the Variable we setup: Call CopyMemory(tItem, ByVal lParam, Len 'If it's our Combobox.. If tItem. CtlType = ODT_COMBOBOX Then 'get the Item Text sItem = Space(255) Call SendMessage sItem = Left(sItem, InStr(sItem, Chr(0)) - 1) 'Select the Highlight Colors if this Item is currently selected If Then lBackBrush = CreateSolidBrush(GetSysColor Call SetBkColor(tItem. hdc, GetSysColor Call SetTextColor(tItem. hdc, GetSysColor Else 'Otherwise, use the default Colors lBackBrush = CreateSolidBrush(GetSysColor Call SetBkColor(tItem. hdc, GetSysColor Call SetTextColor End If FillRect tItem. hdc, tItem. rcItem, lBackBrush 'Display the Item TextOut tItem. hdc, tItem. rcItem. Left, tItem. rcItem. Top, ByVal sItem, Len 'Don't Return a Value as we've dealt with this Message ourselves SubClassedForm = 0 Exit Function End If End If 'Not our Combobox, so just process the Message as Normal SubClassedForm = CallWindowProc End Function Private Function HookApp As Long 'This Function will get called when Initializing the Form 'We want to Interupt it when it tries to create our Combobox.. Dim tCWP As CWPSTRUCT Dim sClass As String Call CopyMemory(tCWP, ByVal lParam, Len If tCWP. message = WM_CREATE Then 'get the Control Classname sClass = Space(128) Call GetClassName(tCWP. hWnd, ByVal sClass, 128) sClass = Left(sClass, InStr(sClass, Chr(0)) - 1) 'If it's our Combobox, Sub-class it to Modify the Create Message.. If sClass = "ComboLBox" Then lSubCombo = SetWindowLong End If End If 'Continue the Hook Processing HookApp = CallNextHookEx End Function Private Function SubComboCreate As Long 'This Function will be called when the Combobox is about to be created Dim tCreate As CREATESTRUCT If Msg = WM_CREATE Then 'Grab the Data that's going to be used to Create the Combobox Call CopyMemory(tCreate, ByVal lParam, Len 'Alter it, to make the Combobox an "Owner Drawn" Control tCreate. style = tCreate. style Or CBS_OWNERDRAWVARIABLE 'Copy the modified data back Call CopyMemory(ByVal lParam, tCreate, Len 'Alter the Style to OwnerDrawn Call SetWindowLong 'Release this Subclassing Function Call SetWindowLong End If 'let Windows Process the Modified Data SubComboCreate = CallWindowProc End Function