|
|
|
Add the following code in form1 and press F5 to run the demo |
Click here to copy the following block | Private Type ChooseColorStruct 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" _ (lpChoosecolor As ChooseColorStruct) As Long Private Declare Function OleTranslateColor Lib "oleaut32.dll" (ByVal lOleColor _ As Long, ByVal lHPalette As Long, lColorRef As Long) As Long Private Const CC_RGBINIT = &H1& Private Const CC_FULLOPEN = &H2& Private Const CC_PREVENTFULLOPEN = &H4& Private Const CC_SHOWHELP = &H8& Private Const CC_ENABLEHOOK = &H10& Private Const CC_ENABLETEMPLATE = &H20& Private Const CC_ENABLETEMPLATEHANDLE = &H40& Private Const CC_SOLIDCOLOR = &H80& Private Const CC_ANYCOLOR = &H100& Private Const CLR_INVALID = &HFFFF
Private Function ShowColorDialog(Optional ByVal hParent As Long, _ Optional ByVal bFullOpen As Boolean, Optional ByVal InitColor As Long) _ As Long Dim CC As ChooseColorStruct Dim aColorRef(15) As Long Dim lInitColor As Long If InitColor <> 0 Then If OleTranslateColor(InitColor, 0, lInitColor) Then lInitColor = CLR_INVALID End If End If With CC .lStructSize = Len(CC) .hwndOwner = hParent .lpCustColors = VarPtr(aColorRef(0)) .rgbResult = lInitColor .flags = CC_SOLIDCOLOR Or CC_ANYCOLOR Or CC_RGBINIT Or IIf(bFullOpen, _ CC_FULLOPEN, 0) End With If ChooseColor(CC) Then ShowColorDialog = CC.rgbResult Else ShowColorDialog = -1 End If End Function
Private Sub Form_Load() ShowColorDialog Me.hwnd, True, vbRed End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
 |

|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|