表示: DelphiC++
表示: Win32LinuxOS X
表示設定

FireMonkey のヒントとこつ

出典: RAD Studio XE2

FireMonkey アプリケーション ガイド への移動

FireMonkey コンポーネント ガイド への移動


目次

一方のフォームをもう一方のフォーム内に埋め込む

コントロールの Parent プロパティを変更することで、一方のフォームをもう一方のフォームの中に埋め込むことができます。 たとえば、以下のコード例では、Form1 のパネル内に Form2 が埋め込まれます。

 uses
   Unit2;
 
 procedure TForm1.FormCreate(Sender: TObject);
 begin
   EmbeddForm(Panel1, TForm2.Create(Self));
 end;
 
   // AParent は、TabControl のパネルやタブシート項目など、どんなコントロールでも可能
 
 procedure EmbeddForm(AParent:TControl; AForm:TCustomForm);
 begin
   while AForm.ChildrenCount>0 do
     AForm.Children[0].Parent:=AParent;
 end;

TSpinBox のプラス ボタンとマイナス ボタンを自動繰り返しモードにする

以下の手続きにより、スピン ボックスの増加矢印と減少矢印のクリック アンド ホールドが可能になります。

 SetRepeatClick(SpinBox1, True);
 
 procedure SetRepeatClick(ASpinBox:TSpinBox; const AValue:Boolean);
 
   procedure SetButton(const AName:String);
   var B : TFmxObject;
   begin
     B := ASpinBox.FindStyleResource(AName);
     if Assigned(B) and (B is TCustomButton) then
        TCustomButton(B).RepeatClick:=AValue;
   end;
 
 begin
   SetButton('minusbutton');
   SetButton('plusbutton');
 end;

グリッドの背景色を変更する方法

スタイル デザイナ ダイアログまたは以下のコードを使って、グリッドの StyleLookup をカスタマイズできます。

 uses
   FMX.Objects;
 
 // グリッドの OnApplyStyleLookup イベントは適切な場所である:
 procedure TForm1.StringGrid1ApplyStyleLookup(Sender: TObject);
 var r : TRectangle;
 begin
   r:=StringGrid1.FindStyleResource('background') as TRectangle;
 
   if Assigned(r) then
      r.Fill.Color:=TAlphaColors.White;
 end;

関連項目

以前のバージョン
他の言語