Hi,
Code below allows to call the ShowColor API wihtout using MS COMDLG.OCX that comes with VB.
It's a SUB.
As you can see, it sets a backcolour of a form in which the sub resides.
Can anyone tell me how convert it to a function, so I can pass any control as a parameter and set this control's backcolour without being restricted to just the form.

' Code:
'----------------------------------------------------
' Form module
'----------------------------------------------------
Private Sub ChooseColour_Click()
Dim CustomColours() As Byte
' Define array for custom colours.
ReDim CustomColours(0 To 15) As Byte
' Resize the array to hold the elements.
Dim tChooseColour As CHOOSECOLOR
' Declare a user-defined variable for the ChooseColour
' type structure.
With tChooseColour
.hwndOwner = Me.hwnd
' Set the handle for the owner of the window.
.lpCustColors = StrConv(CustomColours, vbUnicode)
' Pass the custom colours array after converting
' it to Unicode using the StrConv function.
.flags = 0&
' For this sample, we do not need to use this.
.lStructSize = Len(tChooseColour)
' Set the size of the type structure.
End With
If ShowColour(tChooseColour) = 0 Then MsgBox _
"You clicked on the 'Cancel' button", _
vbExclamation: Exit Sub
' Call the API function and display the ChooseColour
' Common Dialog box, and if the users clicks on cancel
' then the function will return 0.
Me.BackColor = tChooseColour.rgbResult
' Set the back colour of the form with the colour
' that the user selected.
End Sub

'----------------------------------------------------
' Standard module
'----------------------------------------------------
Option Explicit

Public Type CHOOSECOLOR
lStructSize As Long
hwndOwner As Long
hInstance As Long
rgbResult As Long
lpCustColors As String
flags As Long
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type

Public Declare Function ShowColour Lib "comdlg32.dll" Alias "ChooseColorA" (pChoosecolor As CHOOSECOLOR) As Long
'----------------------------------------------------



Thanks for your help.