unit IntListProperty; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, DesignIntf, DesignEditors, IntValuesStr; type TIntListForm = class(TForm) OKBitBtn: TBitBtn; CancelBitBtn: TBitBtn; Memo1: TMemo; procedure Memo1KeyPress(Sender: TObject; var Key: Char); procedure Memo1Change(Sender: TObject); private public end; TIntListProperty = class (TStringProperty) public function GetAttributes: TPropertyAttributes; override; procedure Edit; override; end; var IntListForm: TIntListForm; procedure Register; implementation {$R *.dfm} procedure Register; begin RegisterPropertyEditor( TypeInfo(TIntValuesStr), nil, '', TIntListProperty); end; const Delimiter: Char = ';'; { TIntListPropwrty } {------------------------------- // オブジェクトインスペクタの入力項目を設定する 備考: ダイアログ表示の為の[...]ボタンが付属する //--▼----------------------▽--} function TIntListProperty.GetAttributes: TPropertyAttributes; begin Result := [paDialog]; end; //--△----------------------▲-- {------------------------------- // [...]ボタンを押したときの動作 //--▼----------------------▽--} procedure TIntListProperty.Edit; var IntListForm: TIntListForm; PropertyStr: String; begin IntListForm := TIntListForm.Create(Application); with IntListForm do try PropertyStr := GetStrValue; {↑プロパティの文字列を取得} Memo1.Lines.Clear; Memo1.Lines.Delimiter := Delimiter; Memo1.Lines.DelimitedText := PropertyStr; if ShowModal=mrOk then begin PropertyStr := ''; PropertyStr := Memo1.Lines.DelimitedText; SetStrValue(PropertyStr); {↑プロパティの文字列をセット} Modified; end; finally IntListForm.Free; end; inherited; end; //--△----------------------▲-- {------------------------------- // Memoへのキー入力を数字だけに制限 // Memoの内容がIntegerを示すかどうかチェック //--▼----------------------▽--} procedure TIntListForm.Memo1KeyPress(Sender: TObject; var Key: Char); begin if (Key in ['0'..'9', '+', '-']) or (Key in [Chr(VK_RETURN), Chr(VK_BACK), Chr(VK_DELETE)]) then begin end else begin Key := #0; end; end; procedure TIntListForm.Memo1Change(Sender: TObject); var i: Integer; v: Integer; begin for i := 0 to Memo1.Lines.Count-1 do begin if TryStrToInt(Memo1.Lines[i], v)=False then begin OkBitBtn.Enabled := False; Exit; end; end; OkBitBtn.Enabled := True; end; //--△----------------------▲-- end.