CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Join Date
    Sep 2009
    Posts
    4

    VB6 Color Palette Control / List Box

    Hi All,

    I am building a custom property page for a user control, and would like to add to the form a custom color selector which is same as used on the stock Color Property Page (see attached JPG)

    Any Ideas or solutions ?

    Cheers

    Neil
    Attached Images Attached Images  

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB6 Color Palette Control / List Box

    You can create your own FORM, and use it in your app, or you can create a UAC (User Access Control) that lets you use it in ANY app
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Sep 2009
    Posts
    4

    Re: VB6 Color Palette Control / List Box

    Thanks for the reply, ideally I am trying to find out if this "control" is available any where, as I see it used on a number of thirdpartt controls i.e TrueDBGrid etc.

    Ideally I'd like a complete match, with images in ListBox as in pic, I may develop one using ListView (Easier with images), but was hoping to save some time, if this was available anywhere

    Cheers

    Neil

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB6 Color Palette Control / List Box

    Most tools don't work anymore. I had DevExpress's tools for VB6, but they're gone, as is ActiveX Resizer
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: VB6 Color Palette Control / List Box

    npd, I think this is possible in VB6. I know for a fact it is very easy in VB.NET. Let me see if I can source one of my examples about this in VB 6, for you, else I'll make one in VB.NET and make it compatible with VB 6, and explain to you how to use it

    Sound like a plan ¿

  6. #6
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: VB6 Color Palette Control / List Box

    I'd be curious, too.

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: VB6 Color Palette Control / List Box

    Just an update

    It is possible - a lot of APIs

    I'm busy with it, so hopefully tomorrow I'll be able to post what I have

  8. #8
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Talking Re: VB6 Color Palette Control / List Box

    OK...

    Mine is not so pretty as your shown picure, but it is still pretty funky ( I think so )

    What happens with my project is that it overrides the standard listbox in order to display the system colours ( that you want ). How the list displays them is, with each colour, the item's background is that associated colour.

    Have a look at it, it does work, but if it is not what you wanted, or if you wanted something a bit more funky, I'll see what I can come up with - just note, I have very limited time these days, so I'll try my best for you

    Have fun!

    Hannes
    Last edited by HanneSThEGreaT; June 14th, 2010 at 05:44 AM.

  9. #9
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: VB6 Color Palette Control / List Box

    Not quite the same, but not bad either. Don't know if that's what he wabted, bit I say it looks good.
    I like API juggling.
    Now we would simply have to do a color change/edit routine, say, in the click or doubleclick event of the listbox.

  10. #10
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: VB6 Color Palette Control / List Box

    Yip, not quite the same, I'm also a bit disappointed. It isn't what I intended, hopefully I can find a way to add the pictures - that will look quite funky. Time is a problem these days for me, as some may know. Watch this space !

  11. #11
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB6 Color Palette Control / List Box

    Too complicated. Here's the new way in Windows 7
    Attached Images Attached Images  
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  12. #12
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: VB6 Color Palette Control / List Box

    Seriously, what does that have to do with the OP's original question ¿

    That dialog box is the same in Vista, XP even Windows 98 - you just get to it differently, on each OS ...

  13. #13
    Join Date
    Dec 2001
    Posts
    6,332

    Re: VB6 Color Palette Control / List Box

    Suppose you have a button instead, which opens a standard Property Page at runtime?

    This code apparently works, though I've not tried it:
    http://forums.ni.com/ni/board/messag...essage.id=2001
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  14. #14
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB6 Color Palette Control / List Box

    or this?



    Code:
    Option Explicit
    
    ' cdlCFPrinterFonts &H2
    
    ' Save File Options
    '&H2 - Forces a warning before overwriting a file
    '&H8 - Stops default directory from changing
    '&H200 - more than one file can be selected.
    '&H1000 - This makes it so the file must exist.
    '&H2000 - This warns the user before creating a new file.
    
    Private Sub cmdOpen_Click()
      ' CancelError is True.
       On Error GoTo ErrHandler
       CommonDialog1.InitDir = App.Path
       ' Set Flags
        CommonDialog1.Flags = cdlOFNAllowMultiselect Or cdlOFNLongNames
       ' Set filters.
       CommonDialog1.Filter = "All Files (*.*)|*.*|Text" & _
          "Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
       '  CommonDialog1.Filter = "AutoForm Files (*.doc) (*.rtf)|*.doc;*.rtf|All " & _
              "Files (*.*)|*.*"
       
       ' Specify default filter.
       CommonDialog1.FilterIndex = 2 ' Default to TEXT
       ' Display the Open dialog box.
       CommonDialog1.ShowOpen
       ' Call the open file procedure.
     '  OpenFile (CommonDialog1.FileName)
       Debug.Print CommonDialog1.FileName
       Exit Sub
    
    ErrHandler:
    ' User pressed Cancel button.
       Exit Sub
    
    End Sub
    
    Private Sub cmdShowColor_Click()
      ' Set Cancel to True
      CommonDialog1.CancelError = True
      On Error GoTo ErrHandler
      ' Set the Flags property
      CommonDialog1.Flags = cdlCFEffects Or cdlCFBoth
      ' Display the Font dialog box
      CommonDialog1.ShowColor
      rtb.BackColor = CommonDialog1.Color
      Exit Sub
    ErrHandler:
      ' User pressed the Cancel button
      Exit Sub
    End Sub
    
    Private Sub cmdShowFont_Click()
      ' Set Cancel to True
      CommonDialog1.CancelError = True
      On Error GoTo ErrHandler
      ' Set the Flags property
      CommonDialog1.Flags = cdlCFEffects Or cdlCFBoth ' cdlCFPrinterFonts
      ' Display the Font dialog box
      CommonDialog1.ShowFont
      If rtb.SelLength = 0 Then
        rtb.SelStart = 0
        rtb.SelLength = Len(rtb.SelRTF)
      End If
      rtb.SelFontName = CommonDialog1.FontName
      rtb.SelFontSize = CommonDialog1.FontSize
      rtb.SelBold = CommonDialog1.FontBold
      rtb.SelItalic = CommonDialog1.FontItalic
      rtb.SelUnderline = CommonDialog1.FontUnderline
      rtb.SelStrikeThru = CommonDialog1.FontStrikethru
      rtb.SelColor = CommonDialog1.Color
      Exit Sub
    ErrHandler:
      ' User pressed the Cancel button
      Exit Sub
    End Sub
    
    Private Sub cmdSaveFile_Click()
        Dim strFileName As String
        Dim ans As Integer
        CommonDialog1.Flags = &H2 ' Overwrite Flag
        CommonDialog1.Filter = "RTF|*.rtf|Text|*.txt"
        CommonDialog1.ShowSave
        On Error GoTo SaveProblems
        strFileName = CommonDialog1.FileName
        If CommonDialog1.FilterIndex = 1 Then
            CommonDialog1.DefaultExt = "rtf"
            rtb.SaveFile strFileName
        Else
            CommonDialog1.DefaultExt = "txt"
            rtb.SaveFile strFileName, rtfText
        End If
        Exit Sub
    SaveProblems:
            MsgBox "Can’t save the file, try again.", vbCritical
        Exit Sub
    End Sub
    
    Private Sub Form_Load()
      Label1.Caption = "Open File into RTB " & vbCrLf & _
                       "Save File from RTB" & vbCrLf & _
                       "Show Font" & vbCrLf & _
                       "Change selected text" & vbCrLf & _
                       "       or all text." & vbCrLf & _
                       "Show Color" & vbCrLf & _
                       "Change BackColor of RTB"
    End Sub
    
    Sub SaveMultipleFiles()
        Dim strOrigDir As String
        Dim strNewDir As String
        Dim varTemp As Variant
        Dim lngIdx As Long
            strNewDir = "D:\Temp\"
            With CommonDialog1
            .Flags = cdlOFNAllowMultiselect Or cdlOFNLongNames Or cdlOFNExplorer
            .ShowSave
            varTemp = Split(.FileName, vbNullChar)
        End With
            If IsArray(varTemp) Then
            If UBound(varTemp) = 0 Then
                FileCopy varTemp(lngIdx), strNewDir & Right$(varTemp(lngIdx), Len(varTemp(lngIdx)) - InStrRev(varTemp(lngIdx), "\"))
            Else
                strOrigDir = varTemp(0)
                For lngIdx = LBound(varTemp) + 1 To UBound(varTemp)
                    FileCopy strOrigDir & "\" & varTemp(lngIdx), strNewDir & varTemp(lngIdx)
                Next
            End If
        End If
    End Sub
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  15. #15
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: VB6 Color Palette Control / List Box

    Looks like a standard CommonDialog example to me.

Page 1 of 2 12 LastLast

Tags for this Thread

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

Featured