Results 1 to 11 of 11

Thread: (RESOLVED) Save custom colors

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    154

    Resolved (RESOLVED) Save custom colors

    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:
    1. Option Explicit
    2.  
    3.    Private Type CHOOSECOLOR
    4.      lStructSize As Long
    5.      hwndOwner As Long
    6.      hInstance As Long
    7.      rgbResult As Long
    8.      lpCustColors As String
    9.      flags As Long
    10.      lCustData As Long
    11.      lpfnHook As Long
    12.      lpTemplateName As String
    13.    End Type
    14.  
    15.    Private Declare Function ChooseColorAPI Lib "comdlg32.dll" Alias _
    16.      "ChooseColorA" (pChoosecolor As CHOOSECOLOR) As Long
    17.  
    18.    Dim CustomColors() As Byte
    19.  
    20. Private Sub Form_Load()
    21.        ReDim CustomColors(0 To 16 * 4 - 1) As Byte
    22.        Dim i As Integer
    23.  
    24.        For i = LBound(CustomColors) To UBound(CustomColors)
    25.            CustomColors(i) = 0
    26.        Next i
    27. End Sub
    28.  
    29. Private Sub Command1_Click()
    30.        Dim cc As CHOOSECOLOR
    31.        Dim Custcolor(16) As Long
    32.        Dim lReturn As Long
    33.        cc.lStructSize = Len(cc)
    34.        cc.hwndOwner = Me.hWnd
    35.        cc.hInstance = 0
    36.        cc.lpCustColors = StrConv(CustomColors, vbUnicode)
    37.        cc.flags = 0
    38.        lReturn = ChooseColorAPI(cc)
    39.        If lReturn <> 0 Then
    40.            Text1.Text = cc.rgbResult
    41.            Label1.ForeColor = cc.rgbResult
    42.            CustomColors = StrConv(cc.lpCustColors, vbFromUnicode)
    43.        Else
    44.            'MsgBox "User chose the Cancel Button"
    45.        End If
    46.    End Sub
    Last edited by rdcody; Sep 15th, 2005 at 05:16 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width