我想在工具栏某个按钮的右上区域动态显示数字,类似360软件管家、软件升级图标上提示的数字,如何实现的

解决方案 »

  1.   

    应该是事先做好了多个图标,打包到资源里面,按照IconFile和IconIndex去查询定位对应的数字
    你可以用eXeScope看看管家的EXE和DLL文件,看看图标是怎么一回事
      

  2.   

    TrayIcon,Hint的时候显示相应的数字信息
      

  3.   

    偶收藏的,这是用JAVA写的,做个参考吧.string
    desktopPath
    =
    System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
    IWshRuntimeLibrary.WshShell shell=new WshShell();
    IWshRuntimeLibrary.WshShortcut shortcut = (IWshRuntimeLibrary.WshShortcut)shell.CreateShortcut(desktopPath
    +
    "//个人日记本.lnk");
    string
    exePath
    =
    Application.ExecutablePath;
    //exe路径
    string
    dirPath=System.Environment.CurrentDirectory;
    //directory路径
    //画图部分
    Bitmap
    icoImg = new Bitmap(this.Icon.ToBitmap());
    Graphics graIco = Graphics.FromImage(icoImg);
    graIco.DrawString("1", new Font("Eras Medium
    ITC",
    icoImg.Width/3), new SolidBrush(Color.Red),
    icoImg.Width-icoImg.Width/2,
    0); Icon ico
    =
    Icon.FromHandle(icoImg.GetHicon());
    string
    icoName
    =
    dirPath
    +
    "\\cns.ico";
    Stream stream = new FileStream(icoName,
    FileMode.Create); ico.Save(stream); graIco.Dispose();
    icoImg.Dispose(); //创建图标
    shortcut.WorkingDirectory
    =
    dirPath;
    shortcut.TargetPath = exePath;
    shortcut.IconLocation = dirPath
    +
    "\\cns.ico,0";
    shortcut.WindowStyle = 1;
    shortcut.Save(); 
      

  4.   

    这个就是一个 TImage 和 TLabel 组件组合就行了.
      

  5.   

    就是个Label,关键是控制好实时性和位置。别的没什么难度
      

  6.   

    背景图片 + 文字水印,转换成ico文件,修改快捷方式图标。就这么回事
      

  7.   


    type
      TForm1 = class(TForm)
        ToolBar1: TToolBar;
        ToolButton1: TToolButton;
        ToolButton2: TToolButton;
        ImageList3232: TImageList;
        procedure FormCreate(Sender: TObject);
      private
         procedure ButtonMsg(var Message: TMessage);
       public
      end;
    .............
    procedure TForm1.ButtonMsg(var Message: TMessage);
    var
      X , Y : integer;
    begin
      if Message.Msg=WM_PAINT then begin
        X := ToolButton1.ClientRect.Right - ToolBar1.Canvas.TextWidth('13') - 5;
        Y := ToolButton1.ClientRect.Top + 3;
        ToolBar1.Canvas.Brush.Color := clBlue;
        ToolBar1.Canvas.Brush.Style := bsSolid;
        ToolBar1.Canvas.TextOut(X , Y , '13');
      end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      //指定了就有,未指定就没有数字,注意ButtonMsg指定了对象,自行调整
      ToolBar1.Buttons[0].WindowProc := ButtonMsg;
    end;D7通过.其他版本自行测试
      

  8.   

    360, qq都是用directui做的界面
    按钮, 数字都是图片
    你的效果要求一般的话, 直接canvas画
    否则, 还是图片吧