Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Прикладное программирование » Задачи на Visual Basic (VB).

Модерирует : ShIvADeSt

 Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

Открыть новую тему     Написать ответ в эту тему

dneprcomp



Silver Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Public Function AddToTray()
  'add an icon to the system tray. If is
  'is successful (returns 1) then subclass
  'to intercept messages
   If ShellTrayAdd = 1 Then
   
     'prepare to receive the systray messages
      SubClass Me.hWnd
      Me.Hide
   End If
End Function
 
Public Function ShellTrayAdd() As Long
 
 'prepare the NOTIFYICONDATA type with the
 'required parameters:
 
 '.cbSize: Size of this structure, in bytes.
 '
 '.hwnd:   Handle of the window that will receive
 '         notification messages associated with
 '         an icon in the taskbar status area.
 '
 'uID:     Application-defined identifier of
 '         the taskbar icon. In an application
 '         with a single tray icon, this can be
 '         an arbitrary number.  For apps with
 '         multiple icons, each icon ID must be
 '         different as this member identifies
 '         which of the icons was selected.
 '
 '.uFlags: flags that indicate which of the other
 '         members contain valid data. This member
 '         can be a combination of the following:
 '         NIF_ICON    hIcon member is valid.
 '         NIF_MESSAGE uCallbackMessage member is valid.
 '         NIF_TIP     szTip member is valid.
 '
 'uCallbackMessage: Application-defined message identifier.
 '         The system uses this identifier for
 '         notification messages that it sends
 '         to the window identified in hWnd.
 '         These notifications are sent when a
 '         mouse event occurs in the bounding
 '         rectangle of the icon. (Note: 'callback'
 '         is a bit misused here (in the context of
 '         other callback demonstrations); there is
 '         no systray-specific callback defined -
 '         instead the form itself must be subclassed
 '         to respond to this message.
 '
 'hIcon:   Handle to the icon to add, modify, or delete.
 '
 'szTip:   Tooltip text to display for the icon. Must
 '         be terminated with a Chr$(0).
 
 'Shell_NotifyIcon messages:
 'dwMessage: Message value to send. This parameter
 '           can be one of these values:
 '           NIM_ADD     Adds icon to status area
 '           NIM_DELETE  Deletes icon from status area
 '           NIM_MODIFY  Modifies icon in status area
 '
 'pnid:      Address of the prepared NOTIFYICONDATA.
 '           The content of the structure depends
 '           on the value of dwMessage.
 
 
  strTemp = "abcd"
  With NID
     .cbSize = LenB(NID)
     .hWnd = Me.hWnd
     .uID = 125&
     .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
     .uCallbackMessage = WM_MYHOOK
     .hIcon = Me.Icon
     If strTemp <> "" Then
        .szTip = LoadResString(1192) & "[" & strTemp & "]" & Chr$(0)
     Else
        .szTip = LoadResString(1192) & Chr$(0)
    End If
   End With
 
   ShellTrayAdd = Shell_NotifyIcon(NIM_ADD, NID)
 
End Function
 
Private Sub SubClass(hWnd As Long)
 
  'assign our own window message
  'procedure (WindowProc)
   
   On Error Resume Next
   defWindowProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)
   
End Sub
 
Private Sub UnSubClass()
 
  'restore the default message handling
  'before exiting
   If defWindowProc Then
      SetWindowLong frmOrder.hWnd, GWL_WNDPROC, defWindowProc
      defWindowProc = 0
   End If
   
End Sub
 
Private Sub ShellTrayRemove()
 
  'Remove the icon from the taskbar
   Call Shell_NotifyIcon(NIM_DELETE, NID)
   
End Sub
 
Private Sub Form_Resize()
    'If Tray = vbChecked Then
        If Me.WindowState = vbMinimized Then
            AddToTray
        End If
    'End If
End Sub
 
Private Sub Form_Unload(Cancel As Integer)
    If Tray = vbChecked Then
        'Remove the icon added to the taskbar
         ShellTrayRemove
         
        'remove subclassing
         UnSubClass
    End If
         
    'assure unloading proceeds
     Cancel = False
     
End Sub

Всего записей: 3920 | Зарегистр. 31-03-2002 | Отправлено: 21:51 10-12-2005 | Исправлено: dneprcomp, 05:02 11-12-2005
Открыть новую тему     Написать ответ в эту тему

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Прикладное программирование » Задачи на Visual Basic (VB).


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru