langsung aja sob. ini langkah-langkahnya:
1. buka VB 6.0 anda. buat satu project baru.
2. nah awal anda akan dikasi 1 form yang kosong silakn tambahkan 1 combobox,2 label, dan 1 timer. atur agar seperti berikut
3. Setelah selesai mengatur seperti diatas silakan copy koding dibawah ini di tempat koding form tersebut.
Option Explicit Dim x As String Private Type NotifyIconData Size As Long Handle As Long ID As Long Flags As Long CallBackMessage As Long Icon As Long Tip As String * 64 End Type Private Const AddIcon = &H0 Private Const ModifyIcon = &H1 Private Const DeleteIcon = &H2 Private Const WM_MOUSEMOVE = &H200 Private Const WM_LBUTTONDBLCLK = &H203 Private Const WM_LBUTTONDOWN = &H201 Private Const WM_LBUTTONUP = &H202 Private Const WM_RBUTTONDBLCLK = &H206 Private Const WM_RBUTTONDOWN = &H204 Private Const WM_RBUTTONUP = &H205 Private Const MessageFlag = &H1 Private Const IconFlag = &H2 Private Const TipFlag = &H4 Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal message As Long, Data As NotifyIconData) As Boolean Public unloadfrm As Boolean Private Data As NotifyIconData Private Sub Form_Load() unloadfrm = False CenterMe Me Dim I As Integer Dim J As Integer For I = 1 To 24 For J = 0 To 55 Step 5 Combo1.AddItem I & ":" & Format(J, "00") Next J Next I AddIconToTray Visible = False End Sub Private Sub Form_Terminate() DeleteIconFromTray End Sub Private Sub AddIconToTray() Data.Size = Len(Data) Data.Handle = hWnd Data.ID = vbNull Data.Flags = IconFlag Or TipFlag Or MessageFlag Data.CallBackMessage = WM_MOUSEMOVE Data.Icon = Icon Data.Tip = "Autoshut Down - by D.Shanmuga Sundaram" & vbNullChar Call Shell_NotifyIcon(AddIcon, Data) End Sub Private Sub DeleteIconFromTray() Call Shell_NotifyIcon(DeleteIcon, Data) End Sub Private Function GetWindowState(ByVal Value As Boolean) As Integer GetWindowState = Abs(Value) End Function Private Sub Form_MouseMove(Button As Integer, _ Shift As Integer, x As Single, Y As Single) Dim message As Long message = x / Screen.TwipsPerPixelX Select Case message Case WM_LBUTTONDBLCLK ToggleState Case WM_RBUTTONDOWN Call Me.PopupMenu(menupopup, , , , menuvisible) End Select End Sub Private Sub ToggleState() Visible = Not Visible WindowState = GetWindowState(Not Visible) End Sub Private Sub Form_Unload(Cancel As Integer) If unloadfrm = False Then Me.Hide Cancel = -1 End If End Sub Private Sub MenuVisible_Click() ToggleState End Sub Private Sub Timer1_Timer() If Combo1.Text = "" Then Me.Show Dim J As Integer If Format(Time, "HH:MM") = Trim(Combo1.Text) Then Call shutdown End If End Sub Private Sub Unld_Click() unloadfrm = True Unload Me End Sub |
Option Explicit Public Const EWX_FORCE = 4 Public Const EWX_SHUTDOWN = 1 Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long Public Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long Public Sub CenterMe(ByRef mForm As Form) mForm.Move (Screen.Width - mForm.Width) / 2, (Screen.Height - mForm.Height) / 2 End Sub Public Sub shutdown() ExitWindowsEx EWX_FORCE Or EWX_SHUTDOWN, 0 End Sub |
5. Nah simpan Project kalian. tinggal coba jalankan.
semoga bermanfaat sob,,,
0 comments:
Post a Comment