Полностью согласен со вторым и вот тебе код: Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean Private Declare Function mciSendString Lib "winmm.dll" Alias _ "mciSendStringA" (ByVal lpstrCommand As String, ByVal _ lpstrReturnString As String, ByVal uReturnLength As Long, _ ByVal hwndCallback As Long) As Long Private Const NIM_ADD = &H0 Private Const NIM_MODIFY = &H1 Private Const NIM_DELETE = &H2 Private Const WM_MOUSEMOVE = &H200 Private Const NIF_MESSAGE = &H1 Private Const NIF_ICON = &H2 Private Const NIF_TIP = &H4 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 Type NOTIFYICONDATA cbSize As Long hWnd As Long uId As Long uFlags As Long ucallbackMessage As Long hIcon As Long szTip As String * 64 End Type Dim theForm As NOTIFYICONDATA Private Sub Command1_Click() Me.Hide End Sub Private Sub Command2_Click() Unload Me End Sub
Private Sub Form_Load() Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2 ' запись размера структуры theForm.cbSize = Len(theForm) ' Установка хедера иконки theForm.hWnd = picNotifier.hWnd theForm.hIcon = Me.Icon theForm.uId = 1& 'Установка Флажков 'в данном случие показывать иконку, ' отображать TOOLTIP ' передовать события в форму theForm.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE 'Источник событий мышка theForm.ucallbackMessage = WM_MOUSEMOVE 'Строка тултипа theForm.szTip = "CD-Rom" & Chr$(0) Shell_NotifyIcon NIM_ADD, theForm Me.Hide App.TaskVisible = False End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) ' We also need to remove it when the program ' is ended. ' Change theForm's cbSize to theForm's length. theForm.cbSize = Len(theForm) ' Change theForm's hWnd to picNotifier's hWnd. theForm.hWnd = picNotifier.hWnd ' Change theForm's uId to 1&. theForm.uId = 1& ' Remove it from the TaskBar. Shell_NotifyIcon NIM_DELETE, theForm
End Sub Private Sub mnuPopMenuExit_Click() Unload Me End Sub Private Sub mnuPopMenuShow_Click() Me.Show End Sub Private Sub picNotifier_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'Обработка событий Static Rec As Boolean, Msg As Long Msg = X / Screen.TwipsPerPixelX If Rec = False Then ' Чтоб не повторять Запуск Rec = True Select Case Msg 'Если DoubleClick Case WM_LBUTTONDBLCLK: 'Если левая Кнопка нажата Case WM_LBUTTONDOWN: Dim retvalue retvalue = mciSendString("set CDAudio door open", _ returnstring, 127, 0) 'Если левая Кнопка Отжата Case WM_LBUTTONUP: 'Правая кнопка Click Case WM_RBUTTONDBLCLK: 'Если Правая Кнопка нажата Case WM_RBUTTONDOWN: retvalue = mciSendString("set CDAudio door closed", _ returnstring, 127, 0) 'Если Правая Кнопка Отжата Case WM_RBUTTONUP: PopupMenu mnuPopMenu End Select Rec = False End If End Sub Подкорректируеш, что где тебе надо, намного понятнее чем все эти контролы
Ответить
|