Ver Mensaje Individual
  #5 (permalink)  
Antiguo 06/04/2006, 06:07
Avatar de aldo1982
aldo1982
 
Fecha de Ingreso: noviembre-2004
Ubicación: Santa Fe (Argentina) Colon F.C
Mensajes: 1.362
Antigüedad: 20 años, 5 meses
Puntos: 6
De acuerdo

bue aca te pongo como se hace:
primero ke nada haces un menu con la propiedad invisible (los demas menues ke sean visibles -este menu es para cuando se minimize en el systray) ejemplo: archivo (invisible) > Salir (adentro de archivo -Visible)
bue segun el codigo ke te pongo aca, al primer menu (Archivo seria el Caption) ponele como name (nombre) mnuSystray
bue listo, ya tenes el menu ke va a ser usado cuadno el progama se minimice en el systray (al lado del relojhito)
ahora el siguiente codigo:

declaras en la parte general (option explicit) lo siguiente


Código:
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" _
          (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Private Declare Function SetForegroundWindow Lib "user32" _
          (ByVal hwnd As Long) As Long
Private Type NOTIFYICONDATA
 cbSize As Long             '//size of this UDT
 hwnd As Long               '//handle of the app
 uId As Long                '//unused (set to vbNull)
 uFlags As Long             '//Flags needed for actions
 uCallBackMessage As Long   '//WM we are going to subclass
 hIcon As Long              '//Icon we're going to use for the systray
 szTip As String * 64       '//ToolTip for the mouse_over of the icon.
End Type
Private Const NIM_ADD = &H0             '//Flag : "ALL NEW nid"
Private Const NIM_MODIFY = &H1          '//Flag : "ONLY MODIFYING nid"
Private Const NIM_DELETE = &H2          '//Flag : "DELETE THE CURRENT nid"
Private Const NIF_MESSAGE = &H1         '//Flag : "Message in nid is valid"
Private Const NIF_ICON = &H2            '//Flag : "Icon in nid is valid"
Private Const NIF_TIP = &H4             '//Flag : "Tip in nid is valid"
Private Const WM_MOUSEMOVE = &H200      '//This is our CallBack Message
Private Const WM_LBUTTONDOWN = &H201    '//LButton down
Private Const WM_LBUTTONUP = &H202      '//LButton up
Private Const WM_LBUTTONDBLCLK = &H203  '//LDouble-click
Private Const WM_RBUTTONDOWN = &H204    '//RButton down
Private Const WM_RBUTTONUP = &H205      '//RButton up
Private Const WM_RBUTTONDBLCLK = &H206  '//RDouble-click
Private nid As NOTIFYICONDATA       '//global UDT for the systray function
luego pones este cdigo en el evento Activate del formulario

Código:
With nid
    .cbSize = Len(nid)
    .hwnd = Me.hwnd
    .uId = vbNull
    .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
    .uCallBackMessage = WM_MOUSEMOVE
    .hIcon = Me.Icon
    .szTip = "programa Aldo1982" & vbNullChar 'tooltiptext del systray
  End With
 
  Shell_NotifyIcon NIM_ADD, nid
Este codigo en el evento mousemove del formulario

Código:
Dim msg As Long     '//The callback value
  
  '//The value of X will vary depending
  '//upon the ScaleMode setting.  Here
  '//we are using that fact to determine
  '//what the value of 'msg' should really be
  If (Me.ScaleMode = vbPixels) Then
    msg = X
  Else
    msg = X / Screen.TwipsPerPixelX
  End If

  Select Case msg
    Case WM_LBUTTONDBLCLK    '515 restore form window
      Me.WindowState = vbNormal
      Call SetForegroundWindow(Me.hwnd)
      Me.Show
      
    Case WM_RBUTTONUP        '517 display popup menu
      Call SetForegroundWindow(Me.hwnd)
      Me.PopupMenu Me.mnuSystray
    
    Case WM_LBUTTONUP        '514 restore form window
      '//commonly an application on the
      '//systray will do nothing on a
      '//single mouse_click, so nothing
  End Select
Éste codigo en el evento unload del formulario

Código:
Shell_NotifyIcon NIM_DELETE, nid
   Set Form1 = Nothing  'OJO: Form1 es el nombre de tuformulario
bueno y cuando tu etiqueta (label) sea = 0 o sea

Código:
if val(tulabel) = 0 then
  Form1.WindowState = 1
end if
salu2 y espero te haya servido mi guia jeej nos vemos cualq ddua solo poosteá aqui nos vemos
__________________
LA MUERTE ESTÁ TAN SEGURA DE VENCER QUE NOS DA TODA UNA VIDA DE VENTAJA