⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pepoints.pas

📁 Delphi高级开发指南是开发程序的好帮手
💻 PAS
字号:
unit PePoints;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, DsgnIntf;

type
  TPointsProperty = class (TClassProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure Edit; override;
  end;

procedure Register;

implementation

uses
  DdhGraph, PefPts;

function TPointsProperty.GetAttributes:
  TPropertyAttributes;
begin
  Result := inherited GetAttributes +
    [paDialog] - [paSubProperties];
end;

procedure TPointsProperty.Edit;
var
  Pts: TDdhPoints;
  I: Integer;
begin
  PointsForm := TPointsForm.Create (Application);
  try
    // access to the property
    Pts := TDdhPoints (GetOrdValue);
    with PointsForm.Grid1 do
    begin
      // set the number of rows
      RowCount := Pts.Count;
      // set the width of the three columns
      ColWidths [0] := 50;
      ColWidths [1] := 50;
      ColWidths [2] := ClientWidth - 104;
      // copy the values
      for I := 0 to Pts.Count - 1 do
      begin
        Objects [0, I] := Pts.Items [I];
        Cells [0, I] := IntToStr (Pts.Items [I].X);
        Cells [1, I] := IntToStr (Pts.Items [I].Y);
        Cells [2, I] := Pts.Items [I].Text;
      end; // for
    end; // width

    // show the dialog box
    if PointsForm.ShowModal = mrOK then
    begin
      with PointsForm.Grid1 do
        for I := 0 to Pts.Count - 1 do
        begin
          Pts.Items [I].X := StrToIntDef (Cells [0, I], 0);
          Pts.Items [I].Y := StrToIntDef (Cells [1, I], 0);
          Pts.Items [I].Text := Cells [2, I];
        end;
      // indicate that the component data
      // has changed and should be saved
      Designer.Modified;
      // updates the user interface of the component
      (GetComponent(0) as TDdhGraph).Invalidate;
    end;
  finally
    PointsForm.Free;
  end;
end;

procedure Register;
begin
  RegisterPropertyEditor (TypeInfo(TDdhPoints),
    TDdhGraph, 'Points', TPointsProperty);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -