954,228 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Add color palette to form

I'd like to add a color palette to my form, so that the user can choose a color. How can I add such a palette to my form(with all the colors vb offers)?

plusplus
Posting Whiz in Training
207 posts since Jul 2007
Reputation Points: 10
Solved Threads: 16
 

Hi,
Add this Control to ur ToolBox:
"Microsoft Commom Dialog Control 6.0" to ur Project. Place the Control on the Form and rename it as "cdlg"
and use this Code:

Private Sub Command1_Click()
    Dim mycol
    cdlg.ShowColor
    mycol = cdlg.Color
    Me.BackColor = mycol
End Sub


Regards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

Two questions
1. I'd like to also add the system colors
2. How to move the palette to a certain place on the screen?

plusplus
Posting Whiz in Training
207 posts since Jul 2007
Reputation Points: 10
Solved Threads: 16
 

Hi,

U cannot Control the position of CommonDialog control. But there is an alternative, Place the common Dialog on a New Form, and Move the Form to Desired position on Screen and Show the Form.

Some thing like this : Add a Form And Rename it as frmColor:

Dim frmColor As New frmColor
 frmColor.Move 200,500
 frmColor.cdlg.ShowColor


Not very sure abt system colors...

Regards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

Thanks,works great

plusplus
Posting Whiz in Training
207 posts since Jul 2007
Reputation Points: 10
Solved Threads: 16
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You