(view source code of comdlgcp.vbs as plain text)
' A script to demonstrate the Color Picker dialog available in COMDLG32.OCX
' Written by Rob van der Woude
' http://www.robvanderwoude.com
Option Explicit
Dim intColor
intColor = ColorPicker( )
If Err Then
WScript.Echo "Error: " & Err.Description
Else
WScript.Echo "Selected color (RGB): " & RGB( intColor )
End If
Function ColorPicker( )
Dim objDialog
' Default value if aborted
ColorPicker = 0
On Error Resume Next
Set objDialog = CreateObject( "MSComDlg.CommonDialog" )
If Err Then
MsgBox Err.Description & vbCrLf & vbCrLf & "This script requires COMDLG32.OCX." & vbCrLf & vbCrLf & "Please make sure it is installed and registered.", , "COMDLG32 not registered"
Else
objDialog.ShowColor
ColorPicker = CLng( objDialog.Color )
End If
Set objDialog = Nothing
End Function
Function RGB( myColor )
Dim intTest, strRed, strGreen, strBlue
strRed = CStr( myColor Mod 256 )
intTest = Int( myColor / 256 )
strGreen = CStr( intTest Mod 256 )
intTest = Int( intTest / 256 )
strBlue = CStr( intTest Mod 256 )
RGB = strRed & " " & strGreen & " " & strBlue
End Function
page last modified: 2024-04-16; loaded in 0.0073 seconds