[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
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
Re: CommonDialog.Showcolor via class/module
Thanks! That is exactly what I was looking for and talking about.