Newsgroup: it.comp.lang.visual-basic
Titolo: TrayBar

Salve ragazzi,
    sapete dirmi come minimizzare un'applicazione nella TrayBar?
P.S.: NON mi dite di vedere in MSDN ke nn l'ho trovata!!!
Ciaoo!!

 P.S.: NON mi dite di vedere in MSDN ke nn l'ho trovata!!!
non te lo dico :... di veder MSDN
dunque .... se non ricordo male :
Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias
"Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As
Long
Private Type POINTAPI
   X As Long
   Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As
Long
Private Type NOTIFYICONDATA
    cbSize As Long
    hwnd As Long
    uID As Long
    uFlags As Long
    uCallbackMessage As Long
    hIcon As Long
    sTip As String * 64
End Type
    Private Const NIM_ADD = &H0
    Private Const NIM_MODIFY = &H1
    Private Const NIM_DELETE = &H2
    Private Const NIF_MESSAGE = &H1
    Private Const NIF_ICON = &H2
    Private Const NIF_TIP = &H4
    Private Const NIF_DOALL = NIF_MESSAGE Or NIF_ICON Or NIF_TIP
    Private Const SW_RESTORE = 9
    Private Const SW_MINIMIZE = 6
    Private Const WM_MOUSEMOVE = &H200
    Private Const WM_LBUTTONDBLCLK = &H203
    Private Const WM_RBUTTONUP = &H205
Dim MenùSystray As NOTIFYICONDATA
in Form Load :
Dim Valore As Long
    MenùSystray.cbSize = Len(MenùSystray)
    MenùSystray.hwnd = Me.hwnd
    MenùSystray.uID = vbNull
    MenùSystray.uFlags = NIF_DOALL
    MenùSystray.uCallbackMessage = WM_MOUSEMOVE
    MenùSystray.hIcon = Me.Icon
    MenùSystray.sTip = " Virtual Computers® " & vbNullChar
Valore = Shell_NotifyIcon(NIM_ADD, MenùSystray)
Catturo Gli Eventi Del Mouse :
Form_MouseMove :
     Dim Coordinate As Long
     Dim Coxy  As POINTAPI
    Coordinate = X / Screen.TwipsPerPixelX
       Select Case Coordinate
    Case WM_RBUTTONUP
Usa GetCursorPos per rilevare x,y Esatte
    Tasto destro del Mouse
    Case WM_LBUTTONDBLCLK
            Doppio Clickkkks del Mouse
        End Select
in Fine Form_unload :
Shell_NotifyIcon NIM_DELETE, MenùSystray
Haug !
By Utente Win2k


Cercando si trova anche su MSDN, ma effettivamente non e' perniente
facile (ci sono diventato matto). :-)
In un modulo copia questo...
<VB CODE>
Public 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
Public Const NIM_ADD = &H0    ' Add an icon
Public Const NIM_MODIFY = &H1 ' Modify an icon
Public Const NIM_DELETE = &H2 ' Delete an icon
Public Const NIF_MESSAGE = &H1       ' To change uCallBackMessage member
Public Const NIF_ICON = &H2          ' To change the icon
Public Const NIF_TIP = &H4           ' To change the tooltip text
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201   ' Left click
Public Const WM_LBUTTONDBLCLK = &H203 ' Left double click
Public Const WM_RBUTTONDOWN = &H204   ' Right click
Public Const WM_RBUTTONDBLCLK = &H206 ' Right double click
Public nid As NOTIFYICONDATA
Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As
Boolean
</VB CODE>
In un form crea un Menu con nome "mnuPopup" con le voci che vuoi e copia questo
<VB CODE>
Private Sub Form_Resize()
  If Me.WindowState = vbMinimized Then
    Me.Hide
    AddTrayIcon
  ElseIf Me.WindowState = vbNormal Then
    DeleteTrayIcon
  End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Dim Msg As Long
  Msg = ScaleX(X, ScaleMode, vbPixels)
  Select Case Msg
  Case WM_LBUTTONDOWN
    Me.WindowState = vbNormal
    Me.Show
  Case WM_LBUTTONDBLCLK
  Case WM_RBUTTONDOWN
    PopupMenu mnuPopup
  Case WM_RBUTTONDBLCLK
  End Select
End Sub
Private Sub AddTrayIcon()
  With nid
    .cbSize = Len(nid)
    .hwnd = Me.hwnd
    .uId = 0
    .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
    .uCallBackMessage = WM_MOUSEMOVE
    .hIcon = Me.Icon
    ' Chr$(0) is required at the end of the string
    .szTip = Me.Caption & vbNullChar
  End With
  Shell_NotifyIcon NIM_ADD, nid
End Sub
Private Sub ModifyTrayIcon()
  If Me.WindowState = vbMinimized Then
    nid.szTip = Me.Caption & vbNullChar
    If Not Shell_NotifyIcon(NIM_MODIFY, nid) Then AddTrayIcon
  End If
End Sub
Private Sub DeleteTrayIcon()
  Shell_NotifyIcon NIM_DELETE, nid
End Sub
</VB CODE>
CIAnO

 ha scritto nel messaggio
news:WsdO8.32989$TS.9...@news1.tin.it...



Devi modificare i nomi degli eventi "Form_Resize" e "Form_MouseMove"
in "MDIForm_Resize" e "MDIForm_MouseMove", inoltre i form MDI non hanno
il metodo ScaleX la proprieta ScaleMode, percio' devi modificare la conversione
"Msg = ScaleX(X, ScaleMode, vbPixels)" in "Msg = X / Screen.TwipsPerPixelX"
<VB CODE>
Private Sub MDIForm_Resize()
  If Me.WindowState = vbMinimized Then
    Me.Hide
    AddTrayIcon
  ElseIf Me.WindowState = vbNormal Then
    DeleteTrayIcon
  End If
End Sub
Private Sub MDIForm_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Dim Msg As Long
  'Msg = ScaleX(X, ScaleMode, vbPixels) 'i form MDI non hanno il metodo ScaleX la proprieta ScaleMode
  Msg = X / Screen.TwipsPerPixelX
  Select Case Msg
  Case WM_LBUTTONDOWN
    Me.WindowState = vbNormal
    Me.Show
  Case WM_LBUTTONDBLCLK
  Case WM_RBUTTONDOWN
    PopupMenu mnuPopup
  Case WM_RBUTTONDBLCLK
  End Select
End Sub
</VB CODE>
PS nelle risposte si usa citare (quotare) sotto il messaggio originale non sopra
   eliminando le parti del messaggio non essenziali per esempio il codice VB che
   ho postato io, c'e' un bellissimo post intitolato "[LUNGO][!][OT] CITARE solo
   per chi è nuovo e non conosce la regola" di "Ruscelli David (Home)" che
   spiega molto bene come quotare.
CIAnO

 ke funge solo nei Form e non nei MDI_Form... è normale?
io fungo, tu funghi, egli funge...
Ciao


:-)))
me e' proprio "tu funghi" o piuttosto "tu fungi". :-)
CIAnO

 wrote in message
news:Ub8O8.11760$j65.2...@twister1.libero.it...
