[RESOLVED] How to create a colorpicker like the one in wordpad??
Hi people,
Does one of you know how to create a "simple" colorpicker like the
one in Wordpad? The things i found on the internet are way too big and complicated. That would be overkill. The one like in wordpad would be perfect. I have a Rich TextBox on my form, it would be nice if a user could change the color of the "selected" text.
Hope someone can help..
Thanks,
Warad
Re: How to create a colorpicker like the one in wordpad??
Re: How to create a colorpicker like the one in wordpad??
This is how I am doing it currently in an app...
Firstly, create a command button to call the colour picker....then add a common dialog control to the form.
Then, use this code!
Private Sub Command1_Click()
' This sub allows the user to select a colour
' Common Dialog Parameters
CommonDialog1.CancelError = True
On Error Resume Next
CommonDialog1.ShowColor
If Err.Number = cdlCancel Then
MsgBox "you pressed cancel!"
Exit Sub
End If
On Error GoTo 0
' Save the colour picked via the CommonDialog to a variable...
strColourPicked = CommonDialog1.Color
' Note: this isnt really needed - just showing you the colour picked ... do as you wish with it (probably programmatically adding the colour to the text1 foreground colour or such like?
msgbox = "Colour picked was: " & strColourPicked
End Sub
Hope that helps....working from memory and I am no expert!
Good luck.
Re: How to create a colorpicker like the one in wordpad??
Thanks vbsixer,
I just figurred out how to do this with "Selcolor".
But now i know what the common dialog control is for ;)
Warad
Re: How to create a colorpicker like the one in wordpad??
Quote:
Originally Posted by Warad
But now i know what the common dialog control is for ;)
The common dialog control has a number of uses. Color is just one of them.
Re: How to create a colorpicker like the one in wordpad??
Quote:
Originally Posted by Warad
Thanks vbsixer,
I just figurred out how to do this with "Selcolor".
But now i know what the common dialog control is for ;)
Warad
No bother Warad :thumb:
as Hack says .. the common dialog does so much its scary! Its also used for your opening / saving files, in fact, anything that requires any kind of picking/accessing in a common look and feel i.e. as per most windows app which all look like the common dialog!
Used throughout my app, its also handy for your font picking and other such tasks....plus, users are "used" to it ... ideal!