Link Label
Link label adalah sebuah kontrol Label apabila di klik mouse akan membuka alamat web melalui browser atau mengirimkan e-mail melalui aplikasi e-mail.
[ VB 6.0 ]
Buat sebuah Form dengan sebuah kontrol Label didalamnya.
Di bagian '(Declarations)' dari Form ketikkan :
Private Declare Function LoadCursor Lib "user32.dll" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
Private Declare Function SetCursor Lib "user32.dll" (ByVal hCursor As Long) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function SetCursor Lib "user32.dll" (ByVal hCursor As Long) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Di bagian 'Form_Load' ketikkan :
Label1.ForeColor = vbBlue
Label1.FontUnderline = True
Label1.FontUnderline = True
Di bagian 'Form_MouseMove' ketikkan :
If Label1.ForeColor <> vbBlue Then Label1.ForeColor = vbBlue
Di bagian 'Label1_MouseDown' ketikkan :
SetCursor (LoadCursor(0, 32649))
ShellExecute Me.hwnd, "", "http://www.google.com", "", "", vbMaximizedFocus
Label1.ForeColor = vbBlue
ShellExecute Me.hwnd, "", "http://www.google.com", "", "", vbMaximizedFocus
Label1.ForeColor = vbBlue
Di bagian 'Label1_MouseMove' ketikkan :
SetCursor (LoadCursor(0, 32649))
If Label1.ForeColor <> vbRed Then Label1.ForeColor = vbRed
If Label1.ForeColor <> vbRed Then Label1.ForeColor = vbRed
[ VB .NET ]
Buat Form baru dengan sebuah kontrol LinkLabel didalamnya.
Di bagian 'LinkLabel1_LinkClicked' ketikkan :
System.Diagnostics.Process.Start("http://www.google.com")
CATATAN : Anda bisa mengganti alamat web-nya dengan mengganti kode yang berwarna merah. Jika ingin digunakan untuk mengirimkan e-mail, gantikan kode berwarna merah dengan "mailto:AlamatEmailAnda@yahoo.com"
Label: (Menengah), Kontrol, VB .NET, VB 6.0
0 Komentar:
Posting Komentar
Pengunjung yang baik selalu meninggalkan jejak berupa komentar. :)
Berlangganan Posting Komentar [Atom]
<< Beranda