VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

A Color Picker that works ocx

David Gabrielsen 2  (1 Submission)   OLE/COM/DCOM/Active-X   VB Script   Intermediate   Wed 3rd February 2021

This is a Color Picker, and provides and easy, yet powerful way of picking any color. I've developed it as an ActiveX Control (ocx), and is just as easy to use within your code as the MS-Common Dialog Color Picker.

Inputs
There's only one Function that the developer need to use, which is the ShowColor()- function. Here you can throw 2 optional arguments; 1 : The title of the Dialog, 2 : Any default color you want to be displayed

Assumes
Install : 1. Compile the code into an ocx 2. Add this ocx as an component within your app Usage (Example) : Private Sub ChangeBGColor() Dim myColor As Long 'ctrColorPicker is the name of the OCX myColor = ctrColorPicker.ShowColor("Select a color", vbRed) 'This Control returns -1 if user cancel the 'dialog, so we must make sure the value is 'greater than -1 If myColor > 0 Then txtText.BackColor = myColor End Sub

Returns
The function returns a Long, which is the VB-internal Color

API Declarations
'Install :
'1. Compile the code into an ocx
'2. Add this ocx as an component within your app
'Usage (Example) :
Private Sub ChangeBGColor()
Dim myColor As Long
'ctrColorPicker is the name of the OCX
myColor = ctrColorPicker.ShowColor("Select a color", vbRed)
'This Control returns -1 if user cancel the
'dialog, so we must make sure the value is
'greater than -1
If myColor > -1 Then txtText.BackColor = myColor
End Sub
'There's only one Function that the developer need
'to use, which is the ShowColor()- function. Here
'you can throw 2 optional arguments; 1 : The title
'of the Dialog, 2 : Any default color you want to
'be displayed

Rate A Color Picker that works ocx (5(5 Vote))

Download A Color Picker that works ocx

A Color Picker that works ocx Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters