NotifyIcon:TNotifyIconData;
在给 NotifyIcon 赋值的时候 用了下面这些代码 
      with NotifyIcon do
      begin
        cbSize:=SizeOf(TNotifyIconData);
        Wnd:=Handle; 
        uID:=1;
        uFlags:=NIM_ICON or NIM_MESSAGE or NIM_TIP;
        uCallBackMessage:=WM_NID;
        hIcon:=Application.Icon.Handle;
        szTip:='我是老大';
可是编译的时候说Undeclared identifier:'NIM_ICON'
                Undeclared identifier:'NIM_MESSAGE'
这个是怎么回事啊

解决方案 »

  1.   

    'NIM_ICON'
    'NIM_MESSAGE'两个是其它单元的变量吧用uses语句引用一下定义她的单元吧
      

  2.   

    在uses单元后定义
    const NIM_MESSAGE=WM_USER+10;
    是  NIF_MESSAGE or NIF_ICON or NIF_TIP 吧
      

  3.   

    这是个托盘的示例,你参考一下:
     
    unit  Unit1;  
     
    interface  
     
    uses  
       Windows,  Messages,  SysUtils,  Classes,  Graphics,  Controls,  Forms,  Dialogs, Menus,shellapi;  const  
           WM_TrayMessage=WM_User+100;                 //这句是你要加的
    type  
       TForm1  =  class(TForm)  
           MainMenu1:  TMainMenu;  
           N11:  TMenuItem;  
           N21:  TMenuItem;  
           N22:  TMenuItem;  
           N23:  TMenuItem;  
           N24:  TMenuItem;  
           N31:  TMenuItem;  
           N32:  TMenuItem;  
           PopupMenu1:  TPopupMenu;  
           er1:  TMenuItem;  
           rer1:  TMenuItem;  
           rer2:  TMenuItem;  
           procedure  FormCreate(Sender:  TObject);  
           procedure  FormDestroy(Sender:  TObject);  
           procedure  N21Click(Sender:  TObject);  
           procedure  rer1Click(Sender:  TObject);  
           procedure  FormMouseMove(Sender:  TObject;  Shift:  TShiftState;  X,  
               Y:  Integer);  
       protected  
               procedure  AppMinimized(Sender:  TObject);  
               procedure  WMTrayMessage(var  msg:TMessage);message  WM_TrayMessage;  
     
       private  
           {  Private  declarations  }  
       public  
           {  Public  declarations  }  
       end;  
     
    var  
       Form1:  TForm1;  
           NID:TNotifyIconData;  
     
    implementation  
     
    {$R  *.DFM}  
     
    {  TForm1  }  
     
    procedure  TForm1.AppMinimized(Sender:  TObject);  
    begin  
     NID.cbSize:=SizeOf(TNotifyIconData);  
       NID.hIcon:=Application.Icon.Handle;  
       NID.szTip:=  '工程一  ';  
       NID.uCallbackMessage:=WM_TrayMessage;  
       NID.uFlags:=NIF_ICON  or  NIF_MESSAGE  or  NIF_TIP;           //这句是你要改的
       NID.uID:=0;  
       NID.Wnd:=Handle;  
       Shell_NotifyIcon(NIM_ADD,@NID);  
       ShowWindow(Application.Handle,SW_Hide);  
     
    end;  
     
    procedure  TForm1.WMTrayMessage(var  msg:  TMessage);  
     var  
       p:TPoint;  
    begin  
       if  msg.LParam=WM_LButtonDown  then  
           begin  
               ShowWindow(Application.Handle,SW_Show);  
               Application.Restore;  
           end  
       else  if  msg.LParam=WM_RButtonDown  then  
           begin  
               GetCursorPos(p);  
               PopupMenu1.Popup(p.x,p.y);  
           end;  
    end;  
     
     
     
    procedure  TForm1.FormCreate(Sender:  TObject);  
    //var  Owner  :  HWnd;  
    begin  
     //Owner:=GetWindow(Handle,GW_OWNER);  
     //  ShowWindow(Owner,SW_HIDE);  
     
    Application.OnMinimize:=AppMinimized;  
       AppMinimized(nil);  
     
    end;  
      

  4.   

    uFlags := nif_icon + nif_tip + nif_message; 
              //指定在该结构中uCallbackMessage、hIcon和szTip参数都有效