Hwnd

Iniciado por Pitoniso, 3 Marzo 2006, 21:12 PM

0 Miembros y 1 Visitante están viendo este tema.

Pitoniso

Con este codigo pongo mi Formulario en el Tray, pero lo que necesito es poner otra aplicación en el TRAY ej: Nero, Mozilla... quisiera por favor que me falta y que debo modificar...

Thx

Option Explicit

Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, _
   ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public Const WM_ACTIVATEAPP = &H1C
Public Const NIF_ICON = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_TIP = &H4
Public Const NIM_ADD = &H0
Public Const NIM_DELETE = &H2
Public Const MAX_TOOLTIP As Integer = 64
Public Const GWL_WNDPROC = (-4)

Type NOTIFYICONDATA
   cbSize As Long
   hwnd As Long
   uID As Long
   uFlags As Long
   uCallbackMessage As Long
   hIcon As Long
   szTip As String * MAX_TOOLTIP
End Type

Public nfIconData As NOTIFYICONDATA
Private FHandle As Long     ' Storage for form handle
Private WndProc As Long     ' Address of our handler
Private Hooking As Boolean  ' Hooking indicator

Public Sub AddIconToTray(MeHwnd As Long, MeIcon As Long, MeIconHandle As Long, Tip As String)
With nfIconData
   .hwnd = MeHwnd
   .uID = MeIcon
   .uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
   .uCallbackMessage = WM_RBUTTONUP
   .hIcon = MeIconHandle
   .szTip = Tip & Chr$(0)
   .cbSize = Len(nfIconData)
End With
Shell_NotifyIcon NIM_ADD, nfIconData
End Sub

Public Sub RemoveIconFromTray()
Shell_NotifyIcon NIM_DELETE, nfIconData
End Sub

Public Sub Hook(Lwnd As Long)
If Hooking = False Then
   FHandle = Lwnd
   WndProc = SetWindowLong(Lwnd, GWL_WNDPROC, AddressOf WindowProc)
   Hooking = True
End If
End Sub

Public Sub Unhook()
If Hooking = True Then
   SetWindowLong FHandle, GWL_WNDPROC, WndProc
   Hooking = False
End If
End Sub

If Hooking = True Then
   If uMsg = WM_RBUTTONUP And lParam = WM_RBUTTONDOWN Then
      form1.SysTrayMouseEventHandler  ' Pass the event back to the form handler
      WindowProc = True               ' Let windows know we handled it
      Exit Function
   End If
   WindowProc = CallWindowProc(WndProc, hw, uMsg, wParam, lParam) ' Pass it along
End If
End Function

'in form
Private Sub Command1_Click()
Hook Me.hwnd   ' Set up our handler
AddIconToTray Me.hwnd, Me.Icon, Me.Icon.Handle, "This is a test tip"
Me.Hide
End Sub

' Handler for mouse events occuring in system tray.
Public Sub SysTrayMouseEventHandler()
SetForegroundWindow Me.hwnd
PopupMenu RCPopup, vbPopupMenuRightButton
End Sub

Private Sub msg1_Click()
MsgBox "This is a test message", vbOKOnly, "Hello"
End Sub

Private Sub Rest1_Click()
Unhook    ' Return event control to windows
Me.Show
RemoveIconFromTray
End Sub

Sancho.Mazorka

ehhh... no te entendi un pedo como q queres poner el Mozilla q con tu programa se minimize al Systray los otros?


Sancho.Mazorka     :P
Ganador Xeon Web Server ! ! !    Sancho.Mazorka :D
http://foro.elhacker.net/index.php/topic,171903.75.html



Pitoniso

Lo que necesito es poder Minimizar otra aplicación en el TRAY desde mi programa ej: Mozilla, Nero... el codigo que puse anteriormente es para Minimizar mi Formulario en el TRAY...

Necesito modificarlo.....

Salu2