Programación General > Visual Basic para principiantes

 Utilizar La Paleta De Colores

<< < (2/4) > >>

BoRJiS182:
dudas para mejorar el programa.....

es posible que si haces doble click en un color este se plasme en el label directamente sin necesidad de darle al aceptar de clickar en "aceptar"?


tengo puesto dos opt buttons para seleccionar el color del fondo y del texto...cuando yo pinto mediante la paleta de colores y le cambio a pintar de texto a fondo lo hace sin problemas,pero cuando vuelvo a presionar al opt del texto para cambiar el color del texto ese se cambia solo a uno seleccionado anteriormente por medio de las barras "hsb"¿Hay alguna forma de que mantenga el ultimo color seleccionado de la paleta de colores?

ArKaNtOs:
no, solo se puede de esa manera, lo que puedes hacer es crear tu propia paleta :) aunque creo que te llevaría tiempo, y por lo segundo porque no nos muestras tu código para ver cual es tu problema ;)

BoRJiS182:
Estaba puesto arriba pero lo volveré a poner actualizado....:P


Option Explicit
Public Brojo As Integer
Public Bverde As Integer
Public Bazul As Variant
Public FRojo As Integer
Public Fverde As Integer
Public Fazul As Variant

Private Sub cmdColores_Click()
Me.CommonDialog1.ShowColor
If optColor(0).Value = True Then
    lblCuadro.BackColor = CommonDialog1.Color
Else
    If optColor(1).Value = True Then
        lblCuadro.ForeColor = CommonDialog1.Color
    End If
End If
End Sub

Private Sub cmdSalir_Click()
    End
End Sub

Private Sub Form_Load()
    Brojo = 0
    Bverde = 0
    Bazul = 0
    FRojo = 255
    Fverde = 255
    Fazul = 255
    lblCuadro.BackColor = RGB(Brojo, Bverde, Bazul)
    lblCuadro.ForeColor = RGB(FRojo, Fverde, Fazul)
End Sub

Private Sub hsbColor_Change(Index As Integer)
    If optColor(0).Value = True Then
        lblCuadro.BackColor = RGB(hsbColor(0).Value, hsbColor(1).Value, hsbColor(2).Value)
        Dim i As Integer
        For i = 0 To 2
            txtColor(Index).Text = hsbColor(Index).Value
        Next i
    Else
        lblCuadro.ForeColor = RGB(hsbColor(0).Value, hsbColor(1).Value, hsbColor(2).Value)
        For i = 0 To 2
            txtColor(Index).Text = hsbColor(Index).Value
        Next i
    End If
hsbColor(Index).Value = Val(txtColor(Index).Text)
End Sub

Private Sub optColor_Click(Index As Integer)
    If Index = 0 Then
        Brojo = hsbColor(0).Value
        Bverde = hsbColor(1).Value
        Bazul = hsbColor(2).Value
        hsbColor(0).Value = FRojo
        hsbColor(1).Value = Fverde
        hsbColor(2).Value = Fazul
    Else
        FRojo = hsbColor(0).Value
        Fverde = hsbColor(1).Value
        Fazul = hsbColor(2).Value
        hsbColor(0).Value = Brojo
        hsbColor(1).Value = Bverde
        hsbColor(2).Value = Bazul
    End If
End Sub

Private Sub txtColor_Change(Index As Integer)
    If Val(txtColor(Index).Text) > 255 Then
        hsbColor(Index).Value = 255
    End If
txtColor(Index).Text = Val(txtColor(Index).Text)
hsbColor(Index).Value = Val(txtColor(Index).Text)

End Sub

F_Tanori:
En este procedimiento


--- Código: Text --- Private Sub cmdColores_Click()  Me.CommonDialog1.ShowColor  If optColor(0).Value = True Then     lblCuadro.BackColor = CommonDialog1.Color   ElseIf optColor(1).Value = True Then       lblCuadro.ForeColor = CommonDialog1.Color   End If       long_a_RGB(CommonDialog1.Color)    End IfEnd Sub  
Colocale el valor del color correspondiente a las barras para que lo 'guerde como el ultimo' y te actualice la barras (RGB)


--- Código: Text --- Private Sub Long_a_RGB(ByVal Color)  Dim Rojo As Byte, Verde As Byte, Azul As Byte   Azul = (Color And 16711680) / 65536  Verde = (Color And 65280) / 256  Rojo = Color And 255     hsbColor(0).Value = Rojo    hsbColor(1).Value = Verde    hsbColor(2).Value = Azul  End Sub  

Sera eso lo que necesitas?

Saludos

BoRJiS182:
""Colocale el valor del color correspondiente a las barras para que lo 'guerde como el ultimo' y te actualice la barras (RGB)""


No entedí bien esa frase.....veo la idea pero no se que valor y donde tengo que colocarlo....en la ventana de propiedades???


MUchas gracias por todo!

Navegación

[0] Índice de Mensajes

[#] Página Siguiente

[*] Página Anterior

Ir a la versión completa