Results 1 to 3 of 3

Thread: [RESOLVED] CommonDialog.Showcolor via class/module

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Resolved [RESOLVED] CommonDialog.Showcolor via class/module

    Hi,

    I know it is possible to show the open/save, etc dialog with out needing the common dialog control. However, how would I access the showcolor method via the same way? I could not find an example of it on the forums nor elsewhere on the internet.

    Thanks,


    Nightwalker
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: CommonDialog.Showcolor via class/module

    There's a fairly simple way, using the ChooseColor API. There's an example here http://msdn.microsoft.com/en-us/libr...choosing_color which I've 'converted' to VB
    Code:
    Option Explicit
    
    Private Const CC_FULLOPEN = &H2
    Private Const CC_RGBINIT = &H1
    
    Private Type CHOOSECOLOR
        lStructSize As Long
        hWndOwner As Long
        hInstance As Long
        rgbResult As Long
        lpCustColors As Long
        flags As Long
        lCustData As Long
        lpfnHook As Long
        lpTemplateName As String
    End Type
    
    Private Declare Function CHOOSECOLOR Lib "comdlg32.dll" Alias "ChooseColorA" _
                (pChoosecolor As CHOOSECOLOR) As Long
    
    
    Private Sub cmdColour_Click()
    Static lngCustom(15) As Long
    Static lngCurrent As Long
    Dim lngHandle As Long
    Dim lngResult As Long
    Dim uCol As CHOOSECOLOR
    uCol.lStructSize = Len(uCol)
    uCol.hWndOwner = Me.hWnd
    uCol.lpCustColors = VarPtr(lngCustom(0))
    uCol.rgbResult = lngCurrent
    uCol.flags = CC_FULLOPEN Or CC_RGBINIT
    lngResult = CHOOSECOLOR(uCol)
    If lngResult <> 0 Then
        lngCurrent = uCol.rgbResult
        Debug.Print Hex(lngCurrent)
    End If
    End Sub
    Last edited by Doogle; Apr 17th, 2011 at 01:34 AM. Reason: Corrected Custom Colours code

  3. #3

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: CommonDialog.Showcolor via class/module

    Thanks! That is exactly what I was looking for and talking about.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

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