• Log in or sign up for an account here: https://www.sythe.org/login

[TUT - VB6] Colorbutton: Simple User Control

Blupig

BEEF TOILET
Joined
Nov 23, 2006
Sythe Gold
1,609
Messages
7,145
Age
33
Location
Canada
[TUT - VB6] Colorbutton: Simple User Control
Controls:
-Command Button (1)
-Common Dialog (1)

For common dialog press ctrl+t then select "Microsoft Common Dialog Control" or something like that.

1. Place the controls...anyhwere.

2. Name your command1 ColorButton, and choose a good caption for it like "Choose Skin" or "Change Background". Users will unfortunately not be able to change the caption themselves.

3. Plob this whole slab of code into your user control's code:

Code:
    Event Click()
    
Private Sub ColorButton_Click()
    CommonDialog1.ShowColor
    RaiseEvent Click
    
End Sub

Public Property Get Color() As Long
    Color = CommonDialog1.Color

End Property

Private Sub UserControl_Resize()
    ColorButton.Move 0, 0, ScaleWidth, ScaleHeight

End Sub

When colorbutton gets clicked, the commondialog's color dialog pops up. The color selected is then stored. That last part is the fix to allow resising when a user uses the control in their applications.

4. EXAMPLE USAGE:

Code:
    Form1.BackColor = (control name).Color
 
Runescape Gamblingrunescape gambling
Back
Top