Tutorial llmu llmu komputer dan download program gratis

Memanfaatkan Mouse Event untuk Menggambar pada Form

Mouse Event dalam visual basic bisa kita manfaatkan untuk menggambar pada form dengan menggerakkan mouse. Kali kita akan mengkombinasikan event mousedown dan mousemove.



Buatlah sebuah project standard.exe kemudian tambahkan sebuah CommandButton dan dua buah Option pada form. Design form seperti di bawah!



Isikan kode di bawah

Private Sub Command1_Click()
    Me.Cls
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    CurrentX = X
    CurrentY = Y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        If Option1.Value = True Then
            Line (CurrentX, CurrentY)-(X, Y)
        ElseIf Option2.Value = True Then
            Circle (X, Y), 100
        End If
    End If
End Sub


Download Source Code

Sedikit penjelasan:

Button = 1 artinya gambar akan dicatak ketika sudah klik satu kali. Jika tidak diisi atau 0, maka ketika anda anda menggerakkan mouse pada form akan tercetak gambar secara langsung sebelum anda mengklik pada form.

Me.Cls untuk mengosongkan atau menghapus gambar pada form.

100 pada Circle sebagai diameter lingkaran dalam pixel.

Share on Facebook
Share on Twitter
Share on Google+
Tags :

Related : Memanfaatkan Mouse Event untuk Menggambar pada Form

1 komentar:

  1. WMS. The main ideas of WMS are honesty, innovation, quality, and respect for the players. Some of the most effective pokies in terms of|when it comes to|by method of} image quality and bonus video games. It keeps me entertained and I love my account supervisor, Josh, because of|as a outcome of} he's continually offering me with tricks 코인카지노 to enhance my play experience. The Malta Gaming Authority, extra commonly generally known as|often recognized as} the MGA, is a well-renowned iGaming regulator. The organization safeguards players' rights and aims maintain up} excessive requirements in the industry. The MGA is a pillar of fairness and transparency for players and operators alike.

    ReplyDelete

Silahkan kirimkan komentar atau merequest tutorial...