include("../include.php"); writeHeader("Choose colour dialog", "Programming » Visual Basic 6 » Visual Basic 6 Code » Common Dialogs » ");?>
Private Declare Function ShowColour Lib "comdlg32.dll" Alias "ChooseColorA" _ (pChoosecolor As CHOOSECOLOR) As Long 'ChooseColourType Structure Private 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 Function ChooseColour(hwnd As Long) As Long On Error Resume Next 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 = 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 ChooseColour = -1 Exit Function End If ChooseColour = tChooseColour.rgbResult End Function