Results 1 to 6 of 6

Thread: [RESOLVED] How to create a colorpicker like the one in wordpad??

  1. #1

    Thread Starter
    Member Warad's Avatar
    Join Date
    Feb 2008
    Location
    Netherlands
    Posts
    63

    Resolved [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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to create a colorpicker like the one in wordpad??

    Moved from the CodeBank

  3. #3
    Member
    Join Date
    Feb 2008
    Posts
    37

    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.

  4. #4

    Thread Starter
    Member Warad's Avatar
    Join Date
    Feb 2008
    Location
    Netherlands
    Posts
    63

    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

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  6. #6
    Member
    Join Date
    Feb 2008
    Posts
    37

    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

    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!

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