VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A Color Picker that works ocx

by David Gabrielsen 2 (1 Submission)
Category: OLE/COM/DCOM/Active-X
Compatability: VB Script
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

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
Code 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

Download A Color Picker that works ocx

Download A Color Picker that works ocx (9 KB)

A Color Picker that works ocx Comments

No comments have been posted about A Color Picker that works ocx. Why not be the first to post a comment about A Color Picker that works ocx.

Post your comment

Subject:
Message:
0/1000 characters