Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

A better color picker

Posted on 1998-05-08
7
Medium Priority
?
253 Views
Last Modified: 2008-02-01
Is there a way to let the user pick a color other than using ComCtrl32.dll? I'm looking for either API calls that do not require ComCtrl32 installed on the user's PC or a thirdparty small control that does the job in VB5.
0
Comment
Question by:cellphone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 6

Expert Comment

by:clifABB
ID: 1444221
You could create your own with a form and several shape controls.
0
 
LVL 4

Accepted Solution

by:
zsi earned 200 total points
ID: 1444222
Check out ftp://ftp.cgvb.com/pub/misc/palette.zip for a complete code-based color picker.

zsi
0
 
LVL 4

Expert Comment

by:zsi
ID: 1444223
Here is a description of the program:

Written by Keith Maune
        Email: Keith.Maune@Nashville.com
        WWW Homepage:  http://www.nashville.com/~keith.maune/
  Please write to me about my programs, whether you have a
  question, or just tell me if you like it.

This program allows selecting of 16.7 million colors in a
variety of ways.  You can use scrollbars to change the green,
blue, and red intensities of a color, select the color from
a grid of common colors, or type the hexadecimal code for
the color.  The program displays the seperate red, blue,
and green intensities of the color, the intensity of the color
in decimal form (0-255), the hexadecimal code for the color,
the nearest solid color, and the current color at all times.
You can use this program to select colors for a variety of
purposes.  Or, you can add the included source code to a
Visual Basic project for a complete, ready-to-go color
selection form.

Hope this helps!
zsi
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:cellphone
ID: 1444224
That Was FAST! but his site is down. Can you email me the zip? safari@nbn.com. THANKS!
0
 

Author Comment

by:cellphone
ID: 1444225
Pallette is nice, but I'm looking for something that I don't have to code myself.To use this, I'd have to basicall redo this from scratch to make it compatable with the rest of the app. Is there a way to call the color picker via API or is there a 3rd party control that does the job?
0
 
LVL 4

Expert Comment

by:zsi
ID: 1444226
Oh, that.  Well, the code from the sample app that I referred to isn't complex, but if you want to invoke the color picker from the Common Dialog without using an OCX try this:

Create a form with a command button on it (Commad1) and insert the following code:


Add the following code to the General Declarations section of the form:

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 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
           Me.Caption = "RGB Value User Chose: " & Str$(cc.rgbResult)
           Me.BackColor = cc.rgbResult            ' Visual Basic only ****
           CustomColors = StrConv(cc.lpCustColors, vbFromUnicode)
       Else
           MsgBox "User chose the Cancel Button"
       End If
   End Sub

   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
0
 
LVL 4

Expert Comment

by:zsi
ID: 1444227
There is a much nicer way to do it.  FIll a picture box with a gradient fill offering the entire spectrum available from the color depth (dithered if necessary).  A lot of profrssional graphics packages do this.  

If someone has the code to fill such a box, I will finish out the code to pick the actual color.

zsi
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question