procedure IconOnClick(var message:TMessage); message MI_ICONEVENT;过程声明出错?源程序如下:
  unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,shellapi, ExtCtrls, ImgList, StdCtrls, Buttons, Menus;type
  TForm1 = class(TForm)
    ImageList1: TImageList;
    BitBtn1: TBitBtn;
    PopupMenu1: TPopupMenu;
    PopupMenu2: TPopupMenu;
    hfghfg1: TMenuItem;
    hgfhfg1: TMenuItem;
    hfghfgh1: TMenuItem;
    hfghf1: TMenuItem;
    hfgh1: TMenuItem;
    hgf1: TMenuItem;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    procedure FormCreate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure IconOnClick(var message:TMessage); message MI_ICONEVENT;出错
    procedure BitBtn3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
const
 {托盘图标常量}
   Icon_ID=1;           //图标标识
   MI_ICONEVENT=WM_USER+$1000;
var
  Form1: TForm1;
  ycicon:TNotifyIconData;
  noicon,yesicon:ticon;
  Icon:HICON;   
   implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
 noicon:=ticon.Create;
 noicon:=Self.Icon;
 yesicon:=ticon.Create;
 yesicon:=Self.Icon;
 ycicon.cbSize:=sizeof(TNotifyIconData);
 ycicon.Wnd:=handle;
 ycicon.uID:=Icon_ID;
 ycicon.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
 ycicon.uCallbackMessage:=MI_ICONEVENT;
 ycicon.szTip:='汽车维修管理!';
 ycicon.hIcon:=noicon.Handle;
 shell_notifyicon(nim_add,@ycicon);
end;procedure TForm1.BitBtn1Click(Sender: TObject);
var ycicon:TNotifyIconData;
begin
  ycicon.cbSize:=SizeOf(ycicon);
  ycicon.Wnd:=Handle;
  ycicon.uID:=Icon_ID;
  Shell_NotifyIcon(NIM_DELETE,@ycicon);
end;procedure tform1.IconOnClick(var message:TMessage);// message MI_ICONEVENT;
var p:TPoint;
begin
  if message.LParam=WM_LBUTTONDOWN then   //单击事件
    begin
    GetCursorPos(p);
   //showmessage('PopupMenu2');
   form1.PopupMenu2.popup(p.x,p.y);
    end;
  if message.LParam=WM_LBUTTONDBLCLK then  //双击事件
    form1.Show;
  if message.LParam=WM_RBUTTONDOWN then //右击事件
    begin
    GetCursorPos(p);
    //showmessage('PopupMenu1');
    //form1.PopupMenu1.popup(p.x,p.y);
    showwindow(form1.Handle,sw_shownormal);
    end;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
  form1.Hide;
end;procedure TForm1.BitBtn3Click(Sender: TObject);
begin
form1.PopupMenu2.popup(750,580);
end;end.

解决方案 »

  1.   

    unit Unit1;试一下...
    interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs,shellapi, ExtCtrls, ImgList, StdCtrls, Buttons, Menus;const
     {托盘图标常量}
       Icon_ID=1;           //图标标识
       MI_ICONEVENT=WM_USER+$1000;type
      TForm1 = class(TForm)
        ImageList1: TImageList;
        BitBtn1: TBitBtn;
        PopupMenu1: TPopupMenu;
        PopupMenu2: TPopupMenu;
        hfghfg1: TMenuItem;
        hgfhfg1: TMenuItem;
        hfghfgh1: TMenuItem;
        hfghf1: TMenuItem;
        hfgh1: TMenuItem;
        hgf1: TMenuItem;
        BitBtn2: TBitBtn;
        BitBtn3: TBitBtn;
        procedure FormCreate(Sender: TObject);
        procedure BitBtn1Click(Sender: TObject);
        procedure BitBtn2Click(Sender: TObject);
        procedure IconOnClick(var message:TMessage); message MI_ICONEVENT;出错
        procedure BitBtn3Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    var
      Form1: TForm1;
      ycicon:TNotifyIconData;
      noicon,yesicon:ticon;
      Icon:HICON;   
       implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
    begin
     noicon:=ticon.Create;
     noicon:=Self.Icon;
     yesicon:=ticon.Create;
     yesicon:=Self.Icon;
     ycicon.cbSize:=sizeof(TNotifyIconData);
     ycicon.Wnd:=handle;
     ycicon.uID:=Icon_ID;
     ycicon.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
     ycicon.uCallbackMessage:=MI_ICONEVENT;
     ycicon.szTip:='汽车维修管理!';
     ycicon.hIcon:=noicon.Handle;
     shell_notifyicon(nim_add,@ycicon);
    end;procedure TForm1.BitBtn1Click(Sender: TObject);
    var ycicon:TNotifyIconData;
    begin
      ycicon.cbSize:=SizeOf(ycicon);
      ycicon.Wnd:=Handle;
      ycicon.uID:=Icon_ID;
      Shell_NotifyIcon(NIM_DELETE,@ycicon);
    end;procedure tform1.IconOnClick(var message:TMessage);// message MI_ICONEVENT;
    var p:TPoint;
    begin
      if message.LParam=WM_LBUTTONDOWN then   //单击事件
        begin
        GetCursorPos(p);
       //showmessage('PopupMenu2');
       form1.PopupMenu2.popup(p.x,p.y);
        end;
      if message.LParam=WM_LBUTTONDBLCLK then  //双击事件
        form1.Show;
      if message.LParam=WM_RBUTTONDOWN then //右击事件
        begin
        GetCursorPos(p);
        //showmessage('PopupMenu1');
        //form1.PopupMenu1.popup(p.x,p.y);
        showwindow(form1.Handle,sw_shownormal);
        end;
    end;
    procedure TForm1.BitBtn2Click(Sender: TObject);
    begin
      form1.Hide;
    end;procedure TForm1.BitBtn3Click(Sender: TObject);
    begin
    form1.PopupMenu2.popup(750,580);
    end;end.