XAPPage.pas
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:2k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit XAPPage;
  2. interface
  3. uses
  4.   SysUtils, Windows, Messages, Classes, Graphics, Controls, StdCtrls,
  5.   ExtCtrls, Forms, ComServ, ComObj, StdVcl, AxCtrls, ColorGrd, ComCtrls,
  6.   Dialogs;
  7. type
  8.   TPropertyPage1 = class(TPropertyPage)
  9.     ComboDir: TComboBox;
  10.     Label1: TLabel;
  11.     Label2: TLabel;
  12.     EditHeight: TEdit;
  13.     UpDownHeight: TUpDown;
  14.     Label3: TLabel;
  15.     ShapePen: TShape;
  16.     ShapePoint: TShape;
  17.     Label4: TLabel;
  18.     ButtonPen: TButton;
  19.     ButtonPoint: TButton;
  20.     ColorDialog1: TColorDialog;
  21.     CheckFilled: TCheckBox;
  22.     procedure ButtonPenClick(Sender: TObject);
  23.     procedure ButtonPointClick(Sender: TObject);
  24.   private
  25.     { Private declarations }
  26.   public
  27.     procedure UpdatePropertyPage; override;
  28.     procedure UpdateObject; override;
  29.   end;
  30. const
  31.   Class_PropertyPage1: TGUID = '{CDA51561-914A-11D0-98D0-444553540000}';
  32. implementation
  33. {$R *.DFM}
  34. procedure TPropertyPage1.UpdatePropertyPage;
  35. begin
  36.   { Update your controls from OleObject }
  37.   ComboDir.ItemIndex := OleObject.Direction;
  38.   CheckFilled.Checked := OleObject.Filled;
  39.   EditHeight.Text := IntToStr (OleObject.ArrowHeight);
  40.   ShapePen.Brush.Color := OleObject.PenColor;
  41.   ShapePoint.Brush.Color := OleObject.FillColor;
  42. end;
  43. procedure TPropertyPage1.UpdateObject;
  44. begin
  45.   { Update OleObject from your controls }
  46.   OleObject.Direction := ComboDir.ItemIndex;
  47.   OleObject.Filled := CheckFilled.Checked;
  48.   OleObject.ArrowHeight := UpDownHeight.Position;
  49.   OleObject.PenColor := ColorToRGB (ShapePen.Brush.Color);
  50.   OleObject.FillColor := ColorToRGB (ShapePoint.Brush.Color);
  51. end;
  52. procedure TPropertyPage1.ButtonPenClick(Sender: TObject);
  53. begin
  54.   with ColorDialog1 do
  55.   begin
  56.     Color := ShapePen.Brush.Color;
  57.     if Execute then
  58.     begin
  59.       ShapePen.Brush.Color := Color;
  60.       Modified; // enable Apply button!
  61.     end;
  62.   end;
  63. end;
  64. procedure TPropertyPage1.ButtonPointClick(Sender: TObject);
  65. begin
  66.   with ColorDialog1 do
  67.   begin
  68.     Color := ShapePoint.Brush.Color;
  69.     if Execute then
  70.     begin
  71.       ShapePoint.Brush.Color := Color;
  72.       Modified; // enable Apply button!
  73.     end;
  74.   end;
  75. end;
  76. initialization
  77.   TActiveXPropertyPageFactory.Create(
  78.     ComServer,
  79.     TPropertyPage1,
  80.     Class_PropertyPage1);
  81. end.