Hey All,
I'm using the ChooseColor API to select a color. Is there any way to save the
custom colors a user selects?
Thanks in advance for any help,
Ron
VB Code:
Option Explicit 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 Private Declare Function ChooseColorAPI Lib "comdlg32.dll" Alias _ "ChooseColorA" (pChoosecolor As CHOOSECOLOR) As Long Dim CustomColors() As Byte Private Sub Form_Load() ReDim CustomColors(0 To 16 * 4 - 1) As Byte Dim i As Integer For i = LBound(CustomColors) To UBound(CustomColors) CustomColors(i) = 0 Next i End Sub Private Sub Command1_Click() Dim cc As CHOOSECOLOR Dim Custcolor(16) As Long Dim lReturn As Long cc.lStructSize = Len(cc) cc.hwndOwner = Me.hWnd cc.hInstance = 0 cc.lpCustColors = StrConv(CustomColors, vbUnicode) cc.flags = 0 lReturn = ChooseColorAPI(cc) If lReturn <> 0 Then Text1.Text = cc.rgbResult Label1.ForeColor = cc.rgbResult CustomColors = StrConv(cc.lpCustColors, vbFromUnicode) Else 'MsgBox "User chose the Cancel Button" End If End Sub




Reply With Quote