Ver Mensaje Individual
  #3  
Antiguo 27-02-2008
Avatar de Caral
[Caral] Caral is offline
Miembro Premium
 
Registrado: ago 2006
Posts: 7.659
Reputación: 25
Caral Va por buen camino
Hola
Bienvenido al club.
Hay muchos hilos que muestran como hacerlo, aqui hay un ejempo:
Coloca un PopupMeno en el form y revisa este codigo:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, ShellApi,
  Forms, Dialogs, Menus;

type
  TForm1 = class(TForm)
    PopupMenu1: TPopupMenu;
    Abrir1: TMenuItem;
    procedure Abrir1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    IconData : TNotifyIconData;
    procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
    procedure Espabila(var Msg : TMessage); message WM_USER+1;

  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WMSysCommand(var Msg: TWMSysCommand);
begin
  if (Msg.CmdType = SC_MINIMIZE) then begin
    with IconData do 
    begin 
      cbSize := sizeof(IconData);
      Wnd := Handle;
      uID := 100;
      uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
      uCallbackMessage := WM_USER + 1;
      {Usamos de icono el mismo de la aplicacion}
      {We use the same icon as the application}
      hIcon := Application.Icon.Handle;
      {Como Hint del icono, el nombre de la aplicacion}
      {The name of te app for the hint of the icon}
      StrPCopy(szTip, Application.Title);
    end; 
    {Ponemos el icono al lado del reloj}
    {Place the icon next to the clock}
    Shell_NotifyIcon(NIM_ADD, @IconData);
    {Ocultamos la Form...}
    {Hide the form...}
    Hide;
  end else DefaultHandler(Msg);
end; 

procedure TForm1.Espabila(var Msg : TMessage);
{Aqui se recibe la pulsacion sobre el icono}
{Here we recieve the click on the icon}
var
  p : TPoint;
begin
  if Msg.lParam = WM_RBUTTONDOWN then begin
    SetForegroundWindow(Handle);
    GetCursorPos(p);
    PopupMenu1.Popup(p.x, p.y);
    PostMessage(Handle, WM_NULL, 0, 0);
  end;
end;


procedure TForm1.Abrir1Click(Sender: TObject);
begin
  {Mostramos de nuevo la form}
  {We show the form again}
  Form1.Show;
  ShowWindow(Application.Handle, SW_HIDE);
  {Y nos cargamos el icono de la system tray}
  {Destroy the systray icon}
  Shell_NotifyIcon(NIM_DELETE, @IconData);
  IconData.Wnd:=0;

end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
   {Quitamos el icono (en el caso de haberlo puesto antes...)}
  {Take off the icon (in case of had placed it before.....)}
  if IconData.Wnd <> 0 then Shell_NotifyIcon(NIM_DELETE, @IconData);

end;

procedure TForm1.FormCreate(Sender: TObject);
begin

end;

end.
Saludos
Responder Con Cita