Newsgroup: it.comp.lang.visual-basic
Titolo: Icona nella system tray

C'è modo di fare una applicazione che invece di comparire nella barra delle
applicazioni aperte di WIN compare solo nella System Tray?

 applicazioni aperte di WIN compare solo nella System Tray?
eccoti un modo molto semplice
crea un modulo e incolla il seguente testo:
'===== INIZIO CODICE X MODULO =====
Option Explicit
'Declarations and constants for placing icons in tray
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
Private TrayIcon As NOTIFYICONDATA
Public Const WM_LBUTTONDBLCLICK = &H203
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_RBUTTONDBLCLK = &H206
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public Const WM_MOUSEMOVE = &H200
Const NIM_ADD = &H0
Const NIM_MODIFY = &H1
Const NIM_DELETE = &H2
Const NIF_MESSAGE = &H1
Const NIF_ICON = &H2
Const NIF_TIP = &H4
'API declaration to place icon in tray
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias _
       "Shell_NotifyIconA" (ByVal dwMessage As Long, _
           pnid As NOTIFYICONDATA) As Boolean
Public Sub AddIcon(frm As Form, Optional sTip As String)
    'Sub to place icon in tray
    With TrayIcon
        .cbSize = Len(TrayIcon)
        .hwnd = frm.hwnd
        .uId = vbNull
        .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
        .ucallbackMessage = WM_MOUSEMOVE
        .hIcon = frm.Icon
        'set tool tip text
        If sTip = "" Then
            .szTip = frm.Caption & vbNullChar
        Else
            .szTip = sTip & vbNullChar
        End If
    End With
    'Places icon in tray
    Call Shell_NotifyIcon(NIM_ADD, TrayIcon)
    'Hide the form
    frm.Hide
End Sub
Public Sub RemoveIcon(frm As Form)
    'Sub to remove icon from tray
    With TrayIcon
        .cbSize = Len(TrayIcon)
        .hwnd = frm.hwnd
        .uId = vbNull
    End With
    'Removes icon from tray
    Call Shell_NotifyIcon(NIM_DELETE, TrayIcon)
End Sub
'===== FINE CODICE X MODULO =====
ora incolla quest'altro pezzo di codice nel form principale.
crea un menu invisibile mnuTray (sarà il menu che si aprirà quando farai
clic con il pulsante destro sull'icona nella tray)
'===== INIZIO CODICE FORM =====
Private Sub Form_Load()
    AddIcon Me
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single,
Y As Single)
    Dim lMsg As Long
    lMsg = X / Screen.TwipsPerPixelX
    Select Case lMsg
            Case WM_LBUTTONDBLCLICK
                'code for left button double-click
                Me.WindowState = 0
                Me.Show
            Case WM_LBUTTONDOWN
                'code for left button down
            Case WM_LBUTTONUP
                'code for left button up
            Case WM_RBUTTONDBLCLK
                'code for right button double-clicked
            Case WM_RBUTTONDOWN
                'code for right button down
            Case WM_RBUTTONUP
                'code for right button up
                'typically show a popup menu
                'with at least one menu item
                'to exit the application!
                Me.PopupMenu mnuTray
        End Select
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    RemoveIcon Me
End Sub
Private Sub Form_Resize()
    'Use this code if the ShownInTaskbar
    'property is set to true
    If Me.WindowState = 1 Then
        Me.Hide
        Exit Sub
    End If
    'Other code for form resize event
End Sub
'===== FINE CODICE FORM =====
ciao!
DigitalBlasphemy