PCB论坛网

 找回密码
 注册
查看: 552|回复: 1

Altium Designer 脚本之取得按钮属性

[复制链接]
发表于 2016-8-29 20:34:49 | 显示全部楼层 |阅读模式
本帖最后由 zfaidz 于 2016-8-29 20:35 编辑

如果你不打算写脚本,那么下面的东西你不用看了。


通过正面的脚本,可以得到按钮或者菜单的属性信息,包括标题、描述、图像文件名等等。
文件1     ProcessInfo.pas
  1. Interface
  2. Type
  3.          TForm = Class
  4.                  RichEdit : TRichEdit;
  5.                  Edit : TEdit;
  6.                  Button : TButton;
  7. End;

  8. Var
  9.              TForm1 : TForm;


  10. procedure TForm1.ButtonClick(Sender: TObject);
  11. Var
  12.              guiManager : IGUIManager;
  13.              processInfo : IProcessLauncherInfo;
  14.              imgFile : WideString;
  15. begin
  16.              If Edit.Text = \\\'\\\' Then Edit.Text := \\\'Sch:PlacePort\\\';
  17.              guiManager := Client.GUIManager;
  18.              processInfo := guiManager.GetActivePLByCommand(\\\'SCH\\\',Edit.Text,\\\'\\\');
  19.              imgFile := processInfo.GetImageFile;

  20.              RichEdit.Text := \\\'Process: \\\' + Edit.Text + + #13 +
  21.                               \\\'Caption: \\\' + processInfo.GetCaption + #13 +
  22.                               \\\'Description: \\\' + processInfo.GetDescription + #13 +
  23.                               \\\'Image File: \\\' + imgFile;
  24. end;


  25. procedure TForm1.Form1Create(Sender: TObject);
  26. begin
  27.              RichEdit.Text := \\\'\\\';
  28. end;
复制代码
文件2     ProcessInfo.dfm
  1. object Form1: TForm1
  2.   Left = 0
  3.   Top = 0
  4.   BorderStyle = bsDialog
  5.   Caption = \\\'Form1\\\'
  6.   ClientHeight = 240
  7.   ClientWidth = 640
  8.   Color = clBtnFace
  9.   Font.Charset = DEFAULT_CHARSET
  10.   Font.Color = clWindowText
  11.   Font.Height = -11
  12.   Font.Name = \\\'Tahoma\\\'
  13.   Font.Style = []
  14.   OldCreateOrder = False
  15.   Position = poScreenCenter
  16.   OnCreate = Form1Create
  17.   PixelsPerInch = 96
  18.   TextHeight = 13
  19.   object RichEdit: TRichEdit
  20.     Left = 5
  21.     Top = 8
  22.     Width = 627
  23.     Height = 184
  24.     Font.Charset = GB2312_CHARSET
  25.     Font.Color = clWindowText
  26.     Font.Height = -11
  27.     Font.Name = \\\'Tahoma\\\'
  28.     Font.Style = []
  29.     Lines.Strings = (
  30.       \\\'RichEdit\\\')
  31.     ParentFont = False
  32.     TabOrder = 0
  33.   end
  34.   object Edit: TEdit
  35.     Left = 5
  36.     Top = 207
  37.     Width = 539
  38.     Height = 21
  39.     TabOrder = 1
  40.   end
  41.   object Button: TButton
  42.     Left = 548
  43.     Top = 204
  44.     Width = 75
  45.     Height = 25
  46.     Caption = \\\'Get\\\'
  47.     TabOrder = 2
  48.     OnClick = ButtonClick
  49.   end
  50. end
复制代码




回复

使用道具 举报

发表于 2016-9-9 14:52:02 | 显示全部楼层
楼主,请详细一点讲讲使用方法,谢谢
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|手机版|PCB设计论坛|EDA论坛|PCB论坛网 ( 沪ICP备05006956号-1 )

GMT+8, 2024-6-15 04:53 , Processed in 0.141125 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表