掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
TPopupBoxとほぼ同じコードで見た目が違うのは何故でしょう (ID:151179)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
>TCustomButtonから派生 失礼しました。間違えていました。 しかしながら、クラスヘルパーを使えば、TPopupBoxからの派生でも より短いソースコードで可能かもしれないです。 はずしていたらすいません。 unit UCustomPopupBox; interface uses System.SysUtils, System.Classes, FMX.Types, FMX.Controls, FMX.Controls.Presentation, FMX.StdCtrls, FMX.ExtCtrls, FMX.Pickers ,FMX.Menus; type //クラスヘルパー TPopupBoxHelper=class helper for TPopupBox function GetItemIndexHelper():Integer; procedure SetItemIndexHelper(Value:Integer); end; TCustomPopupBox = class(TPopupBox) private { Private 宣言 } FItemsEx: TStrings; FItemIndexEx:Integer; procedure SetItemsEx(Value:TStrings); procedure FSetItemIndex(const Value: Integer); function FGetItemIndex: Integer; protected { Protected 宣言 } public { Public 宣言 } constructor Create(AOwner: TComponent); override; destructor Destroy; override; published { Published 宣言 } property ItemsEx:TStrings read FItemsEx write SetItemsEx; property ItemIndexEx:Integer read FItemIndexEx write FItemIndexEx; property ItemIndex: Integer read FGetItemIndex write FSetItemIndex default -1; end; procedure Register; implementation uses System.UIConsts, System.Masks, FMX.Platform, System.Math, System.Math.Vectors, FMX.Consts, FMX.Forms, FMX.Utils, System.RTTI; procedure Register; begin RegisterComponents('Samples', [TCustomPopupBox]); end; { TPopupBoxHelper } function TPopupBoxHelper.GetItemIndexHelper: Integer; begin with self do result:=FItemIndex; end; procedure TPopupBoxHelper.SetItemIndexHelper(Value: Integer); begin with self do SetItemIndex(Value); end; { TCustomPopupBox } constructor TCustomPopupBox.Create(AOwner: TComponent); begin inherited; FItemsEx:=TStringList.Create; FItemIndexEx:=-1; end; destructor TCustomPopupBox.Destroy; begin FItemsEx.Free; inherited; end; function TCustomPopupBox.FGetItemIndex: Integer; begin //TPopupBoxのプライベート変数から取り出す Result:=GetItemIndexHelper(); end; procedure TCustomPopupBox.FSetItemIndex(const Value: Integer); begin //TPopupBoxのプライベートメソッドを呼び出す SetItemIndexHelper(Value); if FItemIndexEx<>Value then FItemIndexEx:=Value; end; procedure TCustomPopupBox.SetItemsEx(Value: TStrings); begin FItemsEx.Assign(Value); end; end.
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.