TPanel/ja: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: TPanel/ja
| Old | New | Line | |
|---|---|---|---|
| 1 | + | **TPanel** は、フォーム上にパネルを作成するコンポーネントである。TPanelはTWinControlの派生であり、[[Component Palette/ja|コンポーネントパレットの]][[Standard tab/ja|Standardタブの]]下にある。TPanelは他のコンポーネントの可視コンテナとして機能することができる。 | |
| 2 | + | ||
| 3 | + | ## 例 | |
| 4 | + | ||
| 5 | + | パネルを使用する方法の1つは、コントロールグループを表示および非表示にする場合である。 個々のコントロールを表示または非表示にする代わりに、パネルとそのすべての子コントロールを1つのコマンドで非表示または表示することができる。 この例では、次のコンポーネントが使用されている: [[TButton/ja]], [[TShape]] | |
| 6 | + | ||
| 7 | + | ### Create code | |
| 8 | + | ||
| 9 | + | - 新しい空の[[Graphical User Interface|GUIアプリケーションを]]作成し、[[TForm|form]] Form1を作成します。 | |
| 10 | + | - フォームのOnCreateイベントハンドラを作成するには、フォームをクリックし、オブジェクトインスペクタを使用して、イベントタブに移動し、OnCreateイベントを選択し、\[...\]ボタンをクリックするか、フォーム内のボタンをダブルクリックする。 | |
| 11 | + | - 以下のコードを加える(足りない部分は補うこと): | |
| 12 | + | ||
| 13 | + | ``` pascal | |
| 14 | + | ||
| 15 | + | unit Unit1; | |
| 16 | + | ||
| 17 | + | {$mode objfpc}{$H+} | |
| 18 | + | ||
| 19 | + | interface | |
| 20 | + | ||
| 21 | + | uses | |
| 22 | + | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls; | |
| 23 | + | ||
| 24 | + | type | |
| 25 | + | ||
| 26 | + | { TForm1 } | |
| 27 | + | ||
| 28 | + | TForm1 = class(TForm) | |
| 29 | + | procedure FormCreate(Sender: TObject); | |
| 30 | + | private | |
| 31 | + | aPanel:TPanel; | |
| 32 | + | procedure aButtonClick(Sender: TObject); | |
| 33 | + | public | |
| 34 | + | ||
| 35 | + | end; | |
| 36 | + | ||
| 37 | + | var | |
| 38 | + | Form1: TForm1; | |
| 39 | + | ||
| 40 | + | implementation | |
| 41 | + | ||
| 42 | + | {$R *.lfm} | |
| 43 | + | ||
| 44 | + | { TForm1 } | |
| 45 | + | ||
| 46 | + | procedure TForm1.FormCreate(Sender: TObject); | |
| 47 | + | var | |
| 48 | + | aButton:TButton; | |
| 49 | + | ||
| 50 | + | aShape1,aShape2:TShape; | |
| 51 | + | begin | |
| 52 | + | Caption :='Panel demo'; | |
| 53 | + | aButton:=TButton.Create(Self); | |
| 54 | + | aButton.Parent:=Self; | |
| 55 | + | aButton.Caption:= 'Show/Hide'; | |
| 56 | + | aPanel:=TPanel.Create(Self); | |
| 57 | + | aPanel.Parent:=Self; | |
| 58 | + | aPanel.Caption:=''; | |
| 59 | + | aShape1:=TShape.Create(aPanel); | |
| 60 | + | aShape1.Parent:=aPanel; | |
| 61 | + | aShape1.Shape:=stStar; | |
| 62 | + | aShape1.Top := 5; | |
| 63 | + | aShape2:=TShape.Create(aPanel); | |
| 64 | + | aShape2.Parent:=aPanel; | |
| 65 | + | aShape2.Shape:=stStar; | |
| 66 | + | aShape2.Top := 5; | |
| 67 | + | aShape2.Left:=aShape1.Width+10; | |
| 68 | + | aPanel.Height:=aShape1.Height+10; | |
| 69 | + | aButton.Top:=aPanel.Height+10; | |
| 70 | + | aButton.OnClick:=@aButtonClick; | |
| 71 | + | Height := aButton.Top+aButton.Height+10; | |
| 72 | + | end; | |
| 73 | + | ||
| 74 | + | procedure TForm1.aButtonClick(Sender: TObject); //the event handler for the button | |
| 75 | + | begin | |
| 76 | + | if (Sender is TButton) | |
| 77 | + | then begin | |
| 78 | + | if aPanel.Visible then aPanel.Visible := false else aPanel.Visible := true; | |
| 79 | + | end; | |
| 80 | + | end; | |
| 81 | + | end. | |
| 82 | + | ``` | |
| 83 | + | ||
| 84 | + | ## 以下も参照のこと | |
| 85 | + | ||
| 86 | + | - [[doc:lcl/extctrls/tpanel.html|TPanel doc]] | |
| 87 | + | - [[TBevel]] | |
| 88 | + | - [[TFrame]] | |
| 89 | + | - [[TFlowPanel]] | |
| 90 | + | ||
| 91 | + | --- | |
| 92 | + | *From the Free Pascal wiki, page "TPanel/ja", as it stood on 2024-03-24 after a change by Ariben, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
