zoukankan      html  css  js  c++  java
  • Delphi 之 工具栏组件(TToolBar)

      工具栏组件(TToolBar)为用户提供了快捷菜单的访问方式。

      Buttions

     列出工具栏中的工具按钮,其中保存了TToolButton实例的列表

      Canvas

    在OnCustomDraw或OnCustomDrawItem事件中使用该属性可以在工具栏上画图。

      Constraints

    规定TToolBar的大小限制

      Customizable

    设置该属性为True,允许用户在程序运行时添加、删除和移动工具栏按钮。用户可以按Shift键拖动按钮到一个新的位置,或者拖动它离开

      CusstiomizeKeyName

    使用该属性指定当前用户首次显示工具栏定制的对话框时,保存其按钮配置的位置

      CusstiomizeValueName

    使用该属性指定当前用户首次显示工具栏定制的对话框时,保存其按钮配置名称的位置

      Disabledimages

    该属性包含一个图像列表,每个工具按钮的ImageIndex属性确定了在该按钮上要显示的图标。

      Image

    为TToolBar提供一个图像列表

      Menu

    使用该属性可使工具栏上的按钮与菜单中的项相对应

    示例  利用Canvas属性在TToolBar组件上绘图

     

    procedure TForm1.ToolBar1CustomDraw(Sender: TToolBar; const ARect: TRect;
      var DefaultDraw: Boolean);
    var
      bitmap:TBitmap;
    begin
      bitmap:= TBitmap.Create;
      bitmap.LoadFromFile('C:Documents and SettingsAll UsersDocumentsMy Pictures示例图片MM1.bmp');
      ToolBar1.Canvas.StretchDraw(ARect,bitmap);
      bitmap.Free;
    end;

     示例2 :制作透明按钮效果

    procedure TForm1.ToolBar1CustomDraw(Sender: TToolBar; const ARect: TRect;
      var DefaultDraw: Boolean);
    var
      bitmap:TBitmap;
    begin
      bitmap:= TBitmap.Create;
      bitmap.LoadFromFile('C:Documents and SettingsAll UsersDocumentsMy Pictures示例图片MM1.bmp');
      ToolBar1.Canvas.StretchDraw(ARect,bitmap);
      bitmap.Free;
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      ToolBar1.ShowCaptions:= True;
      ToolBar1.flat:= true;
    end;
    end.

    示例3 按钮OnClick事件实例

    procedure TForm1.ToolButton1Click(Sender: TObject);
    begin
      case (Sender as TToolButton).index of
      0: begin
           ShowMessage('打开程序');
         end;
      1: begin
           ShowMessage('保存程序');
         end;
      end;
    end;
    end.

     

  • 相关阅读:
    HDU 3416 Marriage Match IV(SPFA+最大流)
    asp.net一些很酷很实用的.Net技巧
    asp.net部分控件使用和开发技巧总结
    ASP_NET Global_asax详解
    asp.net 多字段模糊查询代码
    Asp.net中防止用户多次登录的方法
    SQL Server 事务、异常和游标
    有关Cookie
    asp.net 连接sql server 2005 用户 'sa' 登录失败。asp.net开发第一步连接的细节问题
    asp.net生成高质量缩略图通用函数(c#代码),支持多种生成方式
  • 原文地址:https://www.cnblogs.com/delphi2014/p/4024922.html
Copyright © 2011-2022 走看看