Ver Mensaje Individual
  #2  
Antiguo 23-05-2007
Avatar de juanlaplata
juanlaplata juanlaplata is offline
Miembro
 
Registrado: ene 2007
Ubicación: La Plata, Bs. As. (Argentina)
Posts: 212
Reputación: 20
juanlaplata Va por buen camino
Declaraciones
Código Delphi [-]
  private
    { Private declarations }
    IconData: TNewNotifyIconData;
    procedure SysTrayIconMsgHandler(var Msg: TMessage); message TRAY_CALLBACK;
    procedure AddSysTrayIcon;
    procedure ShowBalloonTips(titulo,mensage:string;Icono:integer);
    procedure DeleteSysTrayIcon;
Este procedimiento crea el icono en la bandeja del sistema y muchas cosas mas que no se demasiado.
Código Delphi [-]
procedure TForm1.AddSysTrayIcon;
begin
  IconData.cbSize := SizeOf(IconData);
  IconData.Wnd := AllocateHWnd(SysTrayIconMsgHandler);
  {SysTrayIconMsgHandler is then callback message' handler}
  IconData.uID := 0;
  IconData.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
  IconData.uCallbackMessage := TRAY_CALLBACK;   //user defined callback message
  IconData.hIcon := Application.Icon.Handle;    //an Icon's Handle
  IconData.szTip := '   Titulo de la Aplicacion   ';
  if not Shell_NotifyIcon(NIM_ADD, @IconData) then
    ShowMessage('add fail');
end;
Este procedimiento maneja tanto ballon message como popupMenu en dicho icono, clicks derecho izq, etc
Código Delphi [-]
procedure TForm1.SysTrayIconMsgHandler(var Msg: TMessage);
var Pt: TPoint;
begin
  case Msg.lParam of
    WM_MOUSEMOVE:;
    WM_LBUTTONDOWN:;
    WM_LBUTTONUP:
        begin
        GetCursorPos(Pt);
        SetForeGroundWindow(Application.Handle);
        Application.ProcessMessages;
        PopupMenu1.Popup(Pt.X,Pt.Y);
        end;
    WM_LBUTTONDBLCLK:;
    WM_RBUTTONDOWN:;
    WM_RBUTTONUP:
        begin
        GetCursorPos(Pt);
        SetForeGroundWindow(Application.Handle);
        Application.ProcessMessages;
        PopupMenu1.Popup(Pt.X,Pt.Y);
        end;
    WM_RBUTTONDBLCLK:;
    //followed by the new messages
    NIN_BALLOONSHOW:;
    {Sent when the balloon is shown}
//  ShowMessage('NIN_BALLOONSHOW');
    NIN_BALLOONHIDE: ;
    {Sent when the balloon disappears?Rwhen the icon is deleted,
    for example. This message is not sent if the balloon is dismissed because of
    a timeout or mouse click by the user. }
//  ShowMessage('NIN_BALLOONHIDE');
    NIN_BALLOONTIMEOUT:;
    {Sent when the balloon is dismissed because of a timeout.}
//  ShowMessage('NIN_BALLOONTIMEOUT');
    NIN_BALLOONUSERCLICK:;

    {Sent when the balloon is dismissed because the user clicked the mouse.
    Note: in XP there's Close button on he balloon tips, when click the button,
    send NIN_BALLOONTIMEOUT message actually.}
//    ShowMessage('NIN_BALLOONUSERCLICK');
  end;
end;
Proc. para eliminar el icono
Código Delphi [-]
procedure TForm1.DeleteSysTrayIcon;
begin
  DeallocateHWnd(IconData.Wnd);
  if not Shell_NotifyIcon(NIM_DELETE, @IconData) then
    ShowMessage('delete fail');
end;
En el create del form
Código Delphi [-]
self.AddSysTrayIcon;
En el Destroy
Código Delphi [-]
self.DeleteSysTrayIcon;
Obviamente al no saber mucho de todo esto no lo idee yo, lo encontre buscando "agregar icono en bandeja de sistema".
Espero te sirva, suerte.

Última edición por juanlaplata fecha: 23-05-2007 a las 20:14:08.
Responder Con Cita