Option Explicit
Dim raggp As Boolean
Dim xragg As Single
Dim yragg As Single
Dim pirp As Boolean
Dim xpir As Single
Dim ypir As Single
Dim col
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const VK_SNAPSHOT As Byte = &H2C
Dim mx As Long
Dim my As Long
Dim xc As Single
Dim yc As Single
Dim xc2 As Single
Dim yc2 As Single
Private Sub mnguida_Click()
Dim Shell As Object
Set Shell = CreateObject("Shell.Application")
Shell.Open App.Path & "\" & "Help.txt"
End Sub
Private Sub prelev_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
prelev.Appearance = 1
rettangolo.Appearance = 0
cerchio.Appearance = 0
pennello.Appearance = 0
puntatore.Appearance = 0
Picture1.DrawWidth = CInt(Text1.Text)
matita.Appearance = 0
rettangolor.Appearance = 0
raggp = False
piramide.Appearance = 0
pirp = False
ragg.Appearance = 0
rettangolox.Appearance = 0
linea.Appearance = 0
gomma.Appearance = 0
Picture1.MouseIcon = LoadPicture("")
Picture1.MousePointer = 2
End Sub
Private Sub rand_Click()
Dim min As Integer
Dim xmax As Integer
Dim ymax As Integer
Dim xext As Single
Dim xext2 As Single
Dim yext As Single
Dim yext2 As Single
Dim X As Integer
min = 2
xmax = 1154
ymax = 673
xext = Int((xmax - min + 1) * Rnd) + min
xext2 = Int((xmax - min + 1) * Rnd) + min
yext = Int((ymax - min + 1) * Rnd) + min
yext2 = Int((ymax - min + 1) * Rnd) + min
For X = 1 To CInt(Trim(InputBox("Numero di linee da disegnare (da 1 a 32766)", "Disegno random")))
Picture1.Line (xext, yext)-(xext2, yext2)
xext = Int((xmax - min + 1) * Rnd) + min
xext2 = Int((xmax - min + 1) * Rnd) + min
yext = Int((ymax - min + 1) * Rnd) + min
yext2 = Int((ymax - min + 1) * Rnd) + min
Next
raggp = False
End Sub
Private Sub mncanc_Click()
Picture1.Picture = LoadPicture("")
End Sub
Private Sub mnpulisci_Click()
Picture1.BackColor = Picture1.BackColor
End Sub
Private Sub piramide_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer2.Enabled = False
rettangolox.Appearance = 0
piramide.Appearance = 1
linea.Appearance = 0
Picture1.DrawWidth = CInt(Text1.Text)
If Picture1.ForeColor = &HFFFFFF Then
If col <> "" Then
Picture1.ForeColor = col
Else
End If
Else
End If
Picture1.MouseIcon = LoadPicture("")
Picture1.MousePointer = 2
matita.Appearance = 0
gomma.Appearance = 0
prelev.Appearance = 0
raggp = False
ragg.Appearance = 0
rettangolor.Appearance = 0
rettangolo.Appearance = 0
cerchio.Appearance = 0
puntatore.Appearance = 0
pennello.Appearance = 0
End Sub
Private Sub desk_Click()
If MsgBox("Sei sicuro di voler impostare l'immagine come sfondo del desktop?", vbYesNo, "Ruggy Paint 2") Then
SavePicture Picture1.Image, App.Path & "\Desktops\dsk.bmp"
SystemParametersInfo SPI_SETDESKWALLPAPER, 0, App.Path & "\Desktops\dsk.bmp", SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE
Else
End If
raggp = False
End Sub
Private Sub Form_Load()
Dim g As Integer
Dim w As Long
If App.PrevInstance = True Then
MsgBox "Errore: il programma è già in esecuzione", vbCritical, "Errore"
End
Else
If Command <> "" Then
Picture1.Picture = LoadPicture(Replace$(Command$(), Chr$(34), ""))
Else
End If
Timer2.Enabled = False
raggp = False
pirp = False
matita.Appearance = 1
Form1.Caption = "Ruggy Paint" & " " & App.Major
Form1.AutoRedraw = True
For g = 0 To 255
Form1.Line (0, w)-(Form1.Width, w + 2), RGB(0, g, g), BF
w = w + 3
Next g
Picture1.Width = 1161
Picture1.Height = 681
End If
End Sub
Private Sub gomma_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
col = Picture1.ForeColor
Timer2.Enabled = True
matita.Appearance = 0
piramide.Appearance = 0
rettangolox.Appearance = 0
pirp = False
raggp = False
ragg.Appearance = 0
gomma.Appearance = 1
rettangolo.Appearance = 0
prelev.Appearance = 0
rettangolor.Appearance = 0
pennello.Appearance = 0
linea.Appearance = 0
puntatore.Appearance = 0
cerchio.Appearance = 0
Picture1.DrawWidth = CInt(Text1.Text)
Picture1.ForeColor = Picture1.BackColor
Picture1.MouseIcon = LoadPicture("")
Picture1.MousePointer = 2
End Sub
Private Sub linea_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
linea.Appearance = 1
Picture1.DrawWidth = CInt(Text1.Text)
If Picture1.ForeColor = &HFFFFFF Then
If col <> "" Then
Picture1.ForeColor = col
Else
End If
Else
End If
Picture1.MouseIcon = LoadPicture("")
Picture1.MousePointer = 2
matita.Appearance = 0
gomma.Appearance = 0
rettangolox.Appearance = 0
Timer2.Enabled = False
piramide.Appearance = 0
pirp = False
raggp = False
ragg.Appearance = 0
prelev.Appearance = 0
rettangolor.Appearance = 0
rettangolo.Appearance = 0
cerchio.Appearance = 0
puntatore.Appearance = 0
pennello.Appearance = 0
End Sub
Private Sub matita_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
matita.Appearance = 1
Timer2.Enabled = False
linea.Appearance = 0
raggp = False
ragg.Appearance = 0
gomma.Appearance = 0
cerchio.Appearance = 0
rettangolox.Appearance = 0
rettangolor.Appearance = 0
piramide.Appearance = 0
pirp = False
puntatore.Appearance = 0
rettangolo.Appearance = 0
pennello.Appearance = 0
prelev.Appearance = 0
Picture1.DrawWidth = CInt(Text1.Text)
If Picture1.ForeColor = &HFFFFFF Then
If col <> "" Then
Picture1.ForeColor = col
Else
End If
Else
End If
Picture1.MouseIcon = LoadPicture("")
Picture1.MousePointer = 2
End Sub
Private Sub mnapri_Click()
If MsgBox("Vuoi salvare il file prima di aprirne un altro?", vbYesNo, "Ruggy Paint" & " " & App.Major) = vbNo Then
Else
CommonDialog1.DialogTitle = "Salva"
CommonDialog1.ShowSave
SavePicture Picture1.Image, CommonDialog1.FileName & ".bmp"
End If
CommonDialog1.DialogTitle = "Apri"
CommonDialog1.ShowOpen
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
raggp = False
End Sub
Private Sub mninfo_Click()
Dim msg
msg = MsgBox("Creato da Ruggy94", vbInformation, "Ruggy Paint" & " " & App.Major)
raggp = False
End Sub
Private Sub mnnuovo_Click()
Dim inp
If MsgBox("Vuoi salvare il file prima di creare una nuova immagine?", vbYesNo, "Ruggy Paint" & " " & App.Major) = vbNo Then
Else
CommonDialog1.DialogTitle = "Salva"
CommonDialog1.ShowSave
SavePicture Picture1.Image, CommonDialog1.FileName & ".bmp"
End If
Picture1.Height = CInt(Trim(InputBox("Seleziona l'altezza dell'immagine (da 50 a 681)", "Ruggy Paint 2")))
Picture1.Width = CInt(Trim(InputBox("Seleziona la larghezza dell'immagine (da 50 a 1161)", "Ruggy Paint 2")))
Picture1.ScaleWidth = Picture1.Width
Picture1.Picture = LoadPicture("")
Timdimens.Enabled = True
raggp = False
pirp = False
End Sub
Private Sub mnsalva_Click()
CommonDialog1.DialogTitle = "Salva"
CommonDialog1.ShowSave
SavePicture Picture1.Image, CommonDialog1.FileName & ".bmp"
raggp = False
End Sub
Private Sub ragg_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ragg.Appearance = 1
Timer2.Enabled = False
If Picture1.ForeColor = &HFFFFFF Then
If col <> "" Then
Picture1.ForeColor = col
Else
End If
Else
End If
pennello.Appearance = 0
Picture1.DrawWidth = CInt(Text1.Text)
matita.Appearance = 0
linea.Appearance = 0
rettangolox.Appearance = 0
piramide.Appearance = 0
pirp = False
prelev.Appearance = 0
rettangolo.Appearance = 0
rettangolor.Appearance = 0
puntatore.Appearance = 0
gomma.Appearance = 0
cerchio.Appearance = 0
Picture1.MouseIcon = LoadPicture("")
Picture1.MousePointer = 2
End Sub
Private Sub pennello_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
pennello.Appearance = 1
Timer2.Enabled = False
Picture1.DrawWidth = CInt(Text1.Text)
If Picture1.ForeColor = &HFFFFFF Then
If col <> "" Then
Picture1.ForeColor = col
Else
End If
Else
End If
matita.Appearance = 0
piramide.Appearance = 0
pirp = False
raggp = False
ragg.Appearance = 0
rettangolox.Appearance = 0
linea.Appearance = 0
rettangolo.Appearance = 0
prelev.Appearance = 0
rettangolor.Appearance = 0
puntatore.Appearance = 0
gomma.Appearance = 0
cerchio.Appearance = 0
Picture1.MouseIcon = LoadPicture("")
Picture1.MousePointer = 2
End Sub
Private Sub Picture1_Mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If cerchio.Appearance = 1 Or linea.Appearance = 1 Or rettangolo.Appearance = 1 Or rettangolor.Appearance = 1 Or piramide.Appearance = 1 Or rettangolox.Appearance = 1 Then
xc = X
yc = Y
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Bs As Boolean
If Button Mod 2 = 1 Then Bs = True
If Bs = True Then
If cerchio.Appearance = 0 And puntatore.Appearance = 0 And linea.Appearance = 0 And rettangolo.Appearance = 0 And rettangolor.Appearance = 0 And ragg.Appearance = 0 And piramide.Appearance = 0 And rettangolox.Appearance = 0 And prelev.Appearance = 0 Then
Picture1.Line (mx, my)-(X, Y)
ElseIf ragg.Appearance = 1 Then
If raggp = True Then
Picture1.Line (xragg, yragg)-(X, Y)
Else
End If
End If
End If
mx = X
my = Y
Label3.Caption = CInt(X) & ";" & CInt(Y)
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim xi As Single
Dim rgmax As Integer
Dim rgmin As Integer
Dim rgextr As Single
Dim rgextg As Single
Dim rgextb As Single
If ragg.Appearance = 1 And raggp = False Then
xragg = X
yragg = Y
raggp = True
ElseIf raggp = True Then
raggp = False
End If
If cerchio.Appearance = 1 Then
Picture1.Circle (xc, yc), Sqr((X - xc) * (X - xc) + (Y - yc) * (Y - yc) / 2)
ElseIf linea.Appearance = 1 Then
Picture1.Line (xc, yc)-(X, Y)
ElseIf rettangolo.Appearance = 1 Then
Picture1.Line (xc, yc)-(X, yc)
Picture1.Line (xc, yc)-(xc, Y)
Picture1.Line (X, yc)-(X, Y)
Picture1.Line (xc, Y)-(X, Y)
End If
If piramide.Appearance = 1 And pirp = False Then
xpir = X
ypir = Y
pirp = True
ElseIf pirp = True Then
Picture1.Line (xc, yc)-(X, yc)
Picture1.Line (xc, yc)-(xc, Y)
Picture1.Line (X, yc)-(X, Y)
Picture1.Line (xc, Y)-(X, Y)
Picture1.Line (xpir, ypir)-(xc, yc)
Picture1.Line (xpir, ypir)-(X, Y)
Picture1.Line (xpir, ypir)-(X, yc)
Picture1.Line (xpir, ypir)-(xc, Y)
pirp = False
End If
If rettangolor.Appearance = 1 Then
Picture1.Line (xc, yc)-(X, yc)
Picture1.Line (xc, yc)-(xc, Y)
Picture1.Line (X, yc)-(X, Y)
Picture1.Line (xc, Y)-(X, Y)
If xc < X Then
For xi = xc To X
Picture1.Line (xi, yc)-(xi, Y)
Next
Else
For xi = X To xc
Picture1.Line (xi, Y)-(xi, yc)
Next
End If
End If
If rettangolox.Appearance = 1 Then
Picture1.Line (xc, yc)-(X, yc)
Picture1.Line (xc, yc)-(xc, Y)
Picture1.Line (X, yc)-(X, Y)
Picture1.Line (xc, Y)-(X, Y)
rgmin = 0
rgmax = 255
rgextr = Int((rgmax - rgmin + 1) * Rnd) + rgmin
rgextg = Int((rgmax - rgmin + 1) * Rnd) + rgmin
rgextb = Int((rgmax - rgmin + 1) * Rnd) + rgmin
If xc < X Then
For xi = xc To X
Picture1.Line (xi, yc)-(xi, Y), RGB(rgextr, rgextb, rgextb), BF
rgextr = Int((rgmax - rgmin + 1) * Rnd) + rgmin
rgextg = Int((rgmax - rgmin + 1) * Rnd) + rgmin
rgextb = Int((rgmax - rgmin + 1) * Rnd) + rgmin
Next xi
Else
For xi = X To xc
Picture1.Line (xi, Y)-(xi, yc), RGB(rgextr, rgextg, rgextb), BF
rgextr = Int((rgmax - rgmin + 1) * Rnd) + rgmin
rgextg = Int((rgmax - rgmin + 1) * Rnd) + rgmin
rgextb = Int((rgmax - rgmin + 1) * Rnd) + rgmin
Next
End If
End If
If prelev.Appearance = 1 Then
Picture1.ForeColor = Picture1.Point(X, Y)
Picture3.BackColor = Picture1.Point(X, Y)
End If
End Sub
Private Sub Picture2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture2.Appearance = 1
End Sub
Private Sub Picture2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture2.Appearance = 0
CommonDialog1.ShowColor
Picture1.ForeColor = CommonDialog1.Color
raggp = False
End Sub
Private Sub cerchio_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
cerchio.Appearance = 1
Timer2.Enabled = False
pennello.Appearance = 0
puntatore.Appearance = 0
Picture1.DrawWidth = CInt(Text1.Text)
If Picture1.ForeColor = &HFFFFFF Then
If col <> "" Then
Picture1.ForeColor = col
Else
End If
Else
End If
matita.Appearance = 0
raggp = False
ragg.Appearance = 0
rettangolox.Appearance = 0
prelev.Appearance = 0
rettangolo.Appearance = 0
piramide.Appearance = 0
pirp = False
rettangolor.Appearance = 0
linea.Appearance = 0
gomma.Appearance = 0
Picture1.MouseIcon = LoadPicture("")
Picture1.MousePointer = 2
End Sub
Private Sub posneg_Click()
Dim imm As Long
imm = BitBlt(Picture1.hDC, 0, 0, Picture1.Width, Picture1.ScaleHeight, Picture1.hDC, 0, 0, &H550009)
Picture1.Refresh
raggp = False
End Sub
Private Sub puntatore_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
puntatore.Appearance = 1
Picture1.MouseIcon = LoadPicture(App.Path & "\" & "3dwarro.cur")
Picture1.MousePointer = 99
gomma.Appearance = 0
raggp = False
ragg.Appearance = 0
linea.Appearance = 0
piramide.Appearance = 0
pirp = False
prelev.Appearance = 0
rettangolox.Appearance = 0
rettangolo.Appearance = 0
rettangolor.Appearance = 0
matita.Appearance = 0
pennello.Appearance = 0
cerchio.Appearance = 0
End Sub
Private Sub rettangolo_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
rettangolo.Appearance = 1
Timer2.Enabled = False
cerchio.Appearance = 0
pennello.Appearance = 0
puntatore.Appearance = 0
Picture1.DrawWidth = CInt(Text1.Text)
If Picture1.ForeColor = &HFFFFFF Then
If col <> "" Then
Picture1.ForeColor = col
Else
End If
Else
End If
matita.Appearance = 0
rettangolor.Appearance = 0
raggp = False
piramide.Appearance = 0
pirp = False
ragg.Appearance = 0
rettangolox.Appearance = 0
prelev.Appearance = 0
linea.Appearance = 0
gomma.Appearance = 0
Picture1.MouseIcon = LoadPicture("")
Picture1.MousePointer = 2
End Sub
Private Sub rettangolor_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
rettangolor.Appearance = 1
Timer2.Enabled = False
rettangolo.Appearance = 0
raggp = False
ragg.Appearance = 0
cerchio.Appearance = 0
rettangolox.Appearance = 0
pennello.Appearance = 0
puntatore.Appearance = 0
Picture1.DrawWidth = CInt(Text1.Text)
If Picture1.ForeColor = &HFFFFFF Then
If col <> "" Then
Picture1.ForeColor = col
Else
End If
Else
End If
matita.Appearance = 0
linea.Appearance = 0
piramide.Appearance = 0
pirp = False
prelev.Appearance = 0
gomma.Appearance = 0
Picture1.MouseIcon = LoadPicture("")
Picture1.MousePointer = 2
End Sub
Private Sub rettangolox_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
rettangolox.Appearance = 1
Timer2.Enabled = False
rettangolor.Appearance = 0
rettangolo.Appearance = 0
raggp = False
ragg.Appearance = 0
cerchio.Appearance = 0
prelev.Appearance = 0
pennello.Appearance = 0
puntatore.Appearance = 0
Picture1.DrawWidth = CInt(Text1.Text)
If Picture1.ForeColor = &HFFFFFF Then
If col <> "" Then
Picture1.ForeColor = col
Else
End If
Else
End If
matita.Appearance = 0
linea.Appearance = 0
piramide.Appearance = 0
pirp = False
gomma.Appearance = 0
Picture1.MouseIcon = LoadPicture("")
Picture1.MousePointer = 2
End Sub
Private Sub screen_Click()
Dim lar As Long, alt As Long
Clipboard.Clear
Call keybd_event(VK_SNAPSHOT, 0, 0, 0)
DoEvents
If Width > Picture1.ScaleWidth Then
lar = Picture1.ScaleWidth
alt = (Picture1.ScaleWidth / Width) * Height
Else
lar = Width
alt = Height
End If
Picture1.PaintPicture Clipboard.GetData, 0, 0, lar, alt
raggp = False
End Sub
Private Sub squadra_Click()
Dim col
Timer1.Enabled = False
Picture1.DrawWidth = 1
col = Picture1.ForeColor
Picture1.ForeColor = &H0&
Picture1.Line (20, 20)-(Picture1.Width - 20, 20)
Picture1.Line (20, 20)-(20, Picture1.Height - 20)
Picture1.Line (Picture1.Width - 20, 20)-(Picture1.Width - 20, Picture1.Height - 20)
Picture1.Line (20, Picture1.Height - 20)-(Picture1.Width - 20, Picture1.Height - 20)
Picture1.Line ((Picture1.Width - 20) / 2, 20)-((Picture1.Width - 20) / 2, Picture1.Height - 20)
Picture1.Line (20, (Picture1.Height - 20) / 2)-(Picture1.Width - 20, (Picture1.Height - 20) / 2)
Picture1.ForeColor = col
Timer1.Enabled = True
raggp = False
End Sub
Private Sub Timdimens_Timer()
If Picture1.Height < 50 Then
Picture1.Height = 50
ElseIf Picture1.Height > 681 Then
Picture1.Height = 681
Else
End If
If Picture1.ScaleHeight < 50 Then
Picture1.ScaleHeight = 50
ElseIf Picture1.ScaleHeight > 681 Then
Picture1.ScaleHeight = 681
Else
End If
If Picture1.Width < 50 Then
Picture1.Width = 50
ElseIf Picture1.Width > 1161 Then
Picture1.Width = 1161
Else
End If
If Picture1.ScaleWidth < 50 Then
Picture1.ScaleWidth = 50
ElseIf Picture1.ScaleWidth > 1161 Then
Picture1.ScaleWidth = 1161
Else
End If
Timdimens.Enabled = False
End Sub
Private Sub Timer1_Timer()
Picture3.BackColor = Picture1.ForeColor
If gomma.Appearance = 1 Then
Picture1.ForeColor = Picture1.BackColor
ElseIf matita.Appearance = 1 Then
Picture1.MouseIcon = LoadPicture("")
Picture1.MousePointer = 2
End If
If Text1.Text = "" Then
Text1.Text = "1"
Picture1.DrawWidth = 1
ElseIf CInt(Text1.Text) < 1 Then
Text1.Text = "1"
Picture1.DrawWidth = 1
ElseIf CInt(Text1.Text) > 70 Then
Text1.Text = "70"
Picture1.DrawWidth = 70
End If
Picture1.DrawWidth = CInt(Text1.Text)
If pennello.Appearance = 1 Then
Picture1.DrawWidth = CInt(Text1.Text) + 5
Else
Picture1.DrawWidth = CInt(Text1.Text)
End If
If gomma.Appearance = 1 Then
Picture2.Enabled = False
Picture2.Visible = False
Else
Picture2.Enabled = True
Picture2.Visible = True
End If
Label1.Caption = Now()
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MsgBox("Vuoi salvare il file prima di chiudere il programma?", vbYesNo, "Ruggy Paint" & " " & App.Major) = vbNo Then
End
Else
CommonDialog1.DialogTitle = "Salva"
CommonDialog1.ShowSave
SavePicture Picture1.Image, CommonDialog1.FileName & ".bmp"
End
End If
End Sub
Private Sub Timer2_Timer()
If gomma.Appearance = 1 Then
Picture1.ForeColor = Picture1.BackColor
End If
End Sub