Assalamualaikum, wr, wb..
5. Lalu masukan listing kode dibawah ini pada setiap objeknya
Private Sub Cancel_Click()
Unload Me 'Keluar program
End Sub
Private Sub Form_Load()
Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2 'Kode supaya Form ditengah layar
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
mnufile.Visible = False
If Button = 2 Then PopupMenu mnufile 'jika tombol kanan mouse di klik
End Sub
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
mnufile.Visible = False
If Button = 2 Then PopupMenu mnufile
End Sub
Private Sub Label2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
mnufile.Visible = False
If Button = 2 Then PopupMenu mnufile
End Sub
Membuat menu popup pada mouse
Kali ini saya akan membahas bagaimana caranya membuat menu popup apabila mouse di klik kanan dan akan menampilkan menu popup. Simak caranya ya..
- Seperti biasa buka program Visual basic anda dan mulai dengan form baru, kita akan membuat proyek contohnya.
- Masukan objek-objek seperti gambar dibawah ini :
- Berikut properti objek-objeknya :
- Label1
- Nama = Label1
- Caption = Klik kanan pada form dengan mouse anda maka popup menu akan tampil
- Label2
- Nama = Label2
- Caption = File menu disembunyikan dan bisa ditampilkan property Visivble nya beri nilai True
- CommandButton1
- Nama = Cancel
- Caption = Cancel
5. Lalu masukan listing kode dibawah ini pada setiap objeknya
Private Sub Cancel_Click()
Unload Me 'Keluar program
End Sub
Private Sub Form_Load()
Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2 'Kode supaya Form ditengah layar
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
mnufile.Visible = False
If Button = 2 Then PopupMenu mnufile 'jika tombol kanan mouse di klik
End Sub
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
mnufile.Visible = False
If Button = 2 Then PopupMenu mnufile
End Sub
Private Sub Label2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
mnufile.Visible = False
If Button = 2 Then PopupMenu mnufile
End Sub
6. Jalankan program dengan menekan tombol F5 pada keyboard, dan lihat hasilnya
Selamat mencoba..
Wassalam..n smoga bermanfaat..
0 komentar:
Posting Komentar