DiBR
обычная кошмарная
домашняя страничка
Ежекакполучится околокомпьютерное обозрение
 
  <<<  предыдущий Tech! archive #431 следующий  >>>  
   Последний выпуск       Архив       Ссылки       Полезности       humor.filtered       Фотки       О сайте   
          Это - достаточно беспорядочный архив сообщений конференций сети fidonet, которые на момент их прочтения мной показались полезными или интересными. Многие устарели, многие узкоспецифичны и малоинтересны, но может оказаться и что-то новое...
         
- __techs (2:5015/42) ----------------------------------------------- __techs -
Msg  : 431 of 1000
From : Nick Yegorov                        2:463/132.157   23 Jun 97  17:02:08
To   : Alexander Shherbakov                                24 Jun 97  14:16:24
Subj : Re: SystemTray
-------------------------------------------------------------------------------
@AREA:RU.VISUAL.BASIC
Hello Alexander!

Long time ago, in one galaxy far, far away.....
Monday June 16 1997 17:50, Alexander Shherbakov wrote to All:

AS>      Олл, пояcни плиз, как не имея cоответcтвyющих ОCХ помеcтить иконкy
AS> приложения в Tray?
Вот отрывок из Knowledge Base (для полноценной работы желательно
все-таки иметь Message Blaster или Msg Hooker):

=== Begin kb.txt===

PSS ID Number: Q149276
Article last modified on 04-05-1996

4.00    | 4.00

WINDOWS | WINDOWS NT


------------------------------------------------------------------------
The information in this article applies to:

- Standard, Professional, and Enterprise Editions of Microsoft Visual
  Basic, 32-bit only, for Windows, version 4.0
------------------------------------------------------------------------

SUMMARY
=======

The Windows API provides the ability to add, modify, and remove icons from
the system tray available in the Windows 95 shell. This functionality can
be provided using only the Shell_NotifyIcon function that is exported by
Shell32.dll. This API function also provides the ability to specify a text
string for the ToolTip that is displayed when a user pauses with the mouse
pointer over the icon. The step-by-step example in this article creates a
Visual Basic program which demonstrates how to use this API function.

The ability to take some action if the icon in the systray is clicked
depends on a callback function. Because Visual Basic does not support
callback functions directly, there is no way to show a form or execute some
code using solely Visual Basic. A number of options are available that can
provide callback functionality, including the Message Blaster OCX, the OCX
mentioned in the MSJ article referenced below, or the Callback OLE server
detailed in Bruce McKinney's book, "Hardcore Visual Basic," published by
Microsoft Press. For more information on any of these options, see the
References section at the end of this article. Because these products do
not ship with Visual Basic, AnswerPoint does not support their use.

MORE INFORMATION
================

The following example creates a one-form Visual Basic project that shows
how to use the Shell_NotifyIcon API function.

Step-by-Step Example
--------------------

1. Start Visual Basic. Form1 is created by default.

2. Change the form's icon property to the icon that should be shown in the
  systray.

3. Draw three command buttons onto the form.

4. Select Module from the Insert menu to add a single code module to the
  project.

5. Add the following code, consisting of function, type, and constant
  declarations, to Module1.

  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

  Global Const NIM_ADD = 0
  Global Const NIM_MODIFY = 1
  Global Const NIM_DELETE = 2
  Global Const NIF_MESSAGE = 1
  Global Const NIF_ICON = 2
  Global Const NIF_TIP = 4

  Declare Function Shell_NotifyIconA Lib "SHELL32" _
  (ByVal dwMessage As Long,  lpData As NOTIFYICONDATA) As Integer

5. The following code is a function that takes the parameters that need to
  be set for the NOTIFYICONDATA type and returns a variable of this type.
  Add it to Form1.

  Private Function setNOTIFYICONDATA(hWnd As Long, ID As Long, _
      Flags As Long, CallbackMessage As Long, Icon As Long, _
      Tip As String) As NOTIFYICONDATA

      Dim nidTemp As NOTIFYICONDATA

      nidTemp.cbSize = Len(nidTemp)
      nidTemp.hWnd = hWnd
      nidTemp.uID = ID
      nidTemp.uFlags = Flags
      nidTemp.uCallbackMessage = CallbackMessage
      nidTemp.hIcon = Icon
      nidTemp.szTip = Tip & Chr$(0)

      setNOTIFYICONDATA = nidTemp
  End Function

6. The three procedures in this block of code call the function created in
  step 5 to add, modify, and remove systray icons. Add this code to Form1
  also.

  Private Sub Command1_Click()
      'Add an icon.  This procedure uses the icon specified in the Icon
      'property of Form1.  This can be modified as desired.

      Dim i As Integer
      Dim s As String
      Dim nid As NOTIFYICONDATA

      s = InputBox("Enter string:")
      nid = setNOTIFYICONDATA(hWnd:=Form1.hWnd, _
                              ID:=vbNull, _
                              Flags:=NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
                              CallbackMessage:=vbNull, _
                              Icon:=Form1.Icon, _
                              Tip:=s)

      i = Shell_NotifyIconA(NIM_ADD, nid)
  End Sub

  Private Sub Command2_Click()
      'Modify an existing icon.  This procedure uses the icon specified in
      'the Icon property of Form1.  This can be modified as desired.

      Dim i As Integer
      Dim s As String
      Dim nid As NOTIFYICONDATA

      s = InputBox("Enter string:")
      nid = setNOTIFYICONDATA(hWnd:=Form1.hWnd, _
                              ID:=vbNull, _
                              Flags:=NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
                              CallbackMessage:=vbNull, _
                              Icon:=Form1.Icon, _
                              Tip:=s)

      i = Shell_NotifyIconA(NIM_MODIFY, nid)
  End Sub

  Private Sub Command3_Click()
      'Delete an existing icon.

      Dim i As Integer
      Dim nid As NOTIFYICONDATA

      nid = setNOTIFYICONDATA(hWnd:=Form1.hWnd, _
                              ID:=vbNull, _
                              Flags:=NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
                              CallbackMessage:=vbNull, _
                              Icon:=Form1.Icon, _
                              Tip:="")

      i = Shell_NotifyIconA(NIM_DELETE, nid)
  End Sub

7. Press F5 or select Start from the Run menu to run the application. Click
  the first button and enter a text string to add an icon. Click the
  second button to modify an existing icon, and the third to delete the
  icon.

REFERENCES
==========

Hardcore Visual Basic, Bruce McKinney, Microsoft Press 1995.
Microsoft Win32 SDK, Shell_NotifyIcon and NOTIFYICONDATA.
Microsoft Systems Journal, February 1996, The Visual Programmer, page 93.
Visual Basic Programmer's Journal, March 1996, Q&A, page 136.

Additional reference words: 4.00 vb4win vb432
KBCategory: kbprg kbhowto
KBSubcategory: PrgOther

=============================================================================
Copyright Microsoft Corporation 1996.
=== End kb.txt ===


Best regards,
Nick


--- GoldED/386 2.50+
* Origin: If you can't win fair, just win! (2:463/132.157)






<<<

архив dibr

>>>'