我做了个托盘
代码:
var
nid:   TNotifyIconData;
sql:string;
begin
nid.cbSize:= sizeof(nid);   //   nid变量的字节数
nid.Wnd   := Handle;   //   主窗口句柄
nid.uID   :=1;   //   内部标识,可设为任意数
nid.hIcon := Application.Icon.Handle;   //   要加入的图标句柄,可任意指?StrCopy(nid.szTip, pchar(label2.Caption+getstr));  //   提示字符串
nid.uCallbackMessage   :=   MY_MESSAGE;   //   回调函数消息
nid.uFlags := NIF_ICON   or   NIF_TIP   or   NIF_MESSAGE;   //   指明哪些字段有?
红字部分是鼠标移到小图标商议后会显示一个提示消息:
当日销售金额:问题是要怎么写才能使这个提示消息 在程序运行中随着  getstr  的变化而变化?
比如程序托盘时,我的getstr变成了1000(之前是100)要怎么样写代码才能使的提示小心也相应变成:当日销售金额:1000
求学习啊,在线等    

解决方案 »

  1.   

    当鼠标移动到图标时,Update一次getstr,不久可以了
      

  2.   


    getstr 是一个function   而且 以上托盘图标代码是写在formcreat里面的,请楼上写明代码啊谢谢了
      

  3.   

    unit   Unit5; interface uses 
        Windows,   Messages,   SysUtils,   Variants,   Classes,   Graphics,   Controls,   Forms, 
        Dialogs,   StdCtrls,   ShellApi, Menus, ExtCtrls;const 
        WM_TRAYNOTIFY=WM_USER+1;type 
        TForm1   =   class(TForm)
        Button1: TButton;
        procedure   FormDestroy(Sender:   TObject);
        procedure   Button1Click(Sender:   TObject);
        private
            {   Private   declarations   } 
        public 
            {   Public   declarations   }
            procedure WndProc(var Msg:TMessage);override;
        end; var
        Form1:   TForm1;
        i:Integer;
    implementation {$R   *.dfm} var 
        NotifyIcon:   TNotifyIconData; procedure   TForm1.Button1Click(Sender:   TObject);
    begin
        with   NotifyIcon   do
        begin 
            cbSize   :=   SizeOf(TNotifyIconData); 
            Wnd   :=   Handle; 
            uID   :=   1; 
            uFlags   :=   NIF_ICON   +   NIF_TIP   +   NIF_MESSAGE; 
            uCallbackMessage := WM_TRAYNOTIFY;
            hIcon   :=   Application.Icon.Handle;
            szTip   :=   '临时测试程序';
        end;
        Shell_NotifyIcon(NIM_ADD,   @NotifyIcon);
        Form1.Visible   :=   False;
    end;procedure   TForm1.WndProc(var Msg:TMessage);
    var
      IconID:Integer;
      pt:TPoint;
    begin
      if Msg.Msg = WM_TRAYNOTIFY then
      begin
        IconID:= Msg.WParam;
        GetCursorPos(pt);
        case Msg.LParam of
          WM_LBUTTONDOWN:
          begin
            //鼠标右键按下
          end;
          WM_RBUTTONDOWN:
          begin
            //鼠标左键按下
          end;
          WM_LBUTTONUP:
          begin
            //释放鼠标左键
          end;
          WM_RBUTTONUP:
          begin
            //释放鼠标右键
          end;
          WM_MOUSEMOVE:
          begin
            //鼠标在图标上移动
            NotifyIcon.szTip := '移动';
            Shell_NotifyIcon(NIM_MODIFY,   @NotifyIcon);
          end;
          WM_LBUTTONDBLCLK:
          begin
            //鼠标左键双击
          end;
          WM_RBUTTONDBLCLK:
          begin
            //鼠标右键双击
          end;
        end;
      end else
      inherited;
    end;procedure   TForm1.FormDestroy(Sender:   TObject);
    begin 
        Shell_NotifyIcon(NIM_DELETE,   @NotifyIcon);
    end; end.