Adblock breaks this site

[TUT - VB6] Colorbutton: Simple User Control

Discussion in 'Programming General' started by Blupig, Nov 2, 2007.

  1. Blupig

    Blupig BEEF TOILET
    $5 USD Donor

    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant
    [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
    
     
< [SOURCE] GetBitmap | [TUT - VB6] Using Msgboxes and simple error handling >


 
 
Adblock breaks this site