Paint Basico Visual Basic

June 7, 2023 | Author: Anonymous | Category: N/A
Share Embed Donate


Short Description

Download Paint Basico Visual Basic...

Description

 

En este post les voy a enseñar algo básico en VB 6.0 (Si, ya se que es muy viejo...) pero a algunos les podría dar algo con lo que guiarse en la programación, un paint 

Primero agreguen en este orden los siguientes controles:  Un label (no le pongan nada), un botón (para borrar el dibujo), un picturebox (donde dibujaremos), un shape (para ver el color), un control de tres h_scroll (para cambiar de color) y un checkbox (para decirle al programa que queremos una forma con relleno. 

Si no entendieron lo bien del h_scroll vean esta imagen: 

 

 

Hora del código!!!  'Variables para almacenar las coordenadas _  para los rectángulos y para los círculos Dim X1 As Long Dim Y1 As Long Dim X2 As Long Dim Y2 As Long Private Sub Combo1_Click() Label1.Caption = "Tipo de dibujo: " & Combo1.Text If Combo1.ListIndex = 1 Then Check1.Enabled = True Else Check1.Enabled = False End If End Sub Private Sub Combo1_KeyPress(KeyAscii As Integer) KeyAscii = 0 End Sub

 

Private Sub Command1_Click() Picture1 = Nothing End Sub Private Sub Form_Load() 'Agregamos los valores al combo1 que _ muestra los posibles dibujos a realizar With Combo1 .AddItem "Lápiz" .AddItem "Rectangulo" .AddItem "Circulo" .AddItem "Punto" End With HScroll1(0).Min = 0: HScroll1(1).Min = 0: HScroll1(2).Min = 0 HScroll1(0).Max = 255: HScroll1(1).Max = 255: HScroll1(2).Max = 255 Combo1.ListIndex = 0 End Sub Private Sub HScroll1_Change(Index As Integer) 'Esto le da el color de borde al shape1 _ de acuerdo al valor de los ScrollBar Shape1.BorderColor = RGB(HScroll1(0).Value, HScroll1(1).Value, HScroll1(2).Value) 'Esto le da el color de fondo al shape1 _ de acuerdo al valor de los ScrollBar Shape1.FillColor = RGB(HScroll1(0).Value, HScroll1(1).Value, HScroll1(2).Value) End Sub Private Sub Picture1_MouseDown(Button As Integer, _ Shift As Integer, _  X As Single, Y As Single) 'Almacenamos en estas variables los valores del ratón  X1 = X Y1 = Y  X2 = X Y2 = Y If Combo1.Text = "Rectangulo" Or Combo1.Text = "Circulo" Then Picture1.PSet (X, Y), Shape1.FillColor End If

 

End Sub Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, _  X As Single, Y As Single) If Button = vbLeftButton Then 'Línea continua If Combo1 = "Lápiz" Then Picture1.Line (X1, Y1)-(X, Y), Shape1.FillColor  X1 = X: Y1 = Y End If 'Para dibujar los puntos If Combo1 = "Punto" Then Picture1.PSet (X, Y), Shape1.FillColor End If End If End Sub Private Sub Picture1_MouseUp(Button As Integer, _ Shift As Integer, _  X As Single, _ Y As Single) On Error Resume Next  X1 = 0 Y1 = 0 'Si estamos en modo de rectángulo If Combo1 = "Rectangulo" Then If Check1.Value = 0 Then 'Si no tiene relleno Picture1.Line (X2, Y2)-(X, Y), Shape1.FillColor, B Else 'si tiene relleno Picture1.Line (X2, Y2)-(X, Y), Shape1.FillColor, BF End If End If 'Para los círculos If Combo1 = "Circulo" Then 'sin relleno If X > X2 Then Picture1.Circle (X2, Y2), X - X2, Shape1.FillColor End If 'Con relleno

 

If X2 > X Then Picture1.Circle (X2, Y2), X2 - X, Shape1.FillColor End If End If End Sub

Nota: en la propiedad FillStyle del shape pongala en solid... 

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF