Cara Membuat Jam Digital di Visual Basic - membuat jam dengan mudah menggunakan visual basic 0.6, untuk langkah-langkah cara membuatnya silahkan simak panduannya dibawah ini.
- Buka Microsoft visual basic 0.6
- Buatlah sebuah form seperti berikut ini.
- Untuk tulisan starting menggunakan Label1
- Kemudian buatlah sebuah modul dengan script berikut ini.Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bDefaut As Byte, ByVal dwFlags As Long) As Long
Private Const GWL_EXSTYLE As Long = (-20)
Private Const LWA_COLORKEY As Long = &H1
Private Const LWA_Defaut As Long = &H2
Private Const WS_EX_LAYERED As Long = &H80000
Public Function Transparency(ByVal hWnd As Long, Optional ByVal Col As Long = vbBlack, Optional ByVal PcTransp As Byte = 255, Optional ByVal TrMode As Boolean = True) As Boolean
' Return : True if there is no error.
' hWnd : hWnd of the window to make transparent
' Col : Color to make transparent if TrMode=False
' PcTransp : 0 Ã 255 >> 0 = transparent -:- 255 = Opaque
Dim DisplayStyle As Long
On Error GoTo err1
VoirStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
If DisplayStyle <> (DisplayStyle Or WS_EX_LAYERED) Then
DisplayStyle = (DisplayStyle Or WS_EX_LAYERED)
Call SetWindowLong(hWnd, GWL_EXSTYLE, DisplayStyle)
End If
Transparency = (SetLayeredWindowAttributes(hWnd, Col, PcTransp, IIf(TrMode, LWA_COLORKEY Or LWA_Defaut, LWA_COLORKEY)) <> 0)
err1:
If Not Err.Number = 0 Then Err.Clear
End Function
Public Sub ActiveTransparency(M As Form, d As Boolean, F As Boolean, _
T_Transparency As Integer, Optional Color As Long)
Dim B As Boolean
If d And F Then
'Makes color (here the background color of the shape) transparent
'upon value of T_Transparency
B = Transparency(M.hWnd, Color, T_Transparency, False)
ElseIf d Then
'Makes form, including all components, transparent
'upon value of T_Transparency
B = Transparency(M.hWnd, 0, T_Transparency, True)
Else
'Restores the form opaque.
B = Transparency(M.hWnd, , 255, True)
End If
End Sub - Masukan script berikut ini, pada formPrivate Sub Form_Load()
Dim d As Long
Dim s As Long
Timer1.Enabled = True
Form1.Top = 0
s = Screen.Width
d = Screen.Width - (Screen.Width - Form1.Width)
Form1.Left = s - d
Dim i As Integer
'Ex: all transparent at ratio 140/255
'ActiveTransparency Me, True, False, 140, Me.BackColor
'Ex: Form transparent, visible component at ratio 140/255
'ActiveTransparency Me, True, True, 140, Me.BackColor
'Example display the form transparency degradation
ActiveTransparency Me, True, False, 0
Me.Show
For i = 0 To 255 Step 3
ActiveTransparency Me, True, False, i
Me.Refresh
Next i
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Time
Label2.Left = Label2.Left - 100
If Label2.Left <= 0 Then
Label2.Left = 6360
End If
End Sub - Selesai ...
DOWNLOAD SOURCECODE
Demikian artikel mengenai Cara Membuat Jam Digital di Visual Basic semoga dapat bermanfaat bagi anda.
0 Comments