Sign in Join
Wiki copytemporary

TPanel/fi: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: TPanel/fi

OldNewLine
1+**TPanel** ![](/wiki-images/5/57/Tpanel.png) on komponentti, joka luo paneelin lomakkeelle. TPanel on [[TWinControl|TWinControlin]] jälkeläinen ja on saatavana [[Component Palette/fi|komponenttipaletin]] [[Standard tab/fi|Standard]]-välilehdeltä. TPanel voi toimia näkyvänä säiliönä muille komponenteille.
2+
3+## Esimerkki
4+
5+Eräs tapa käyttää paneeleja on, kun kaikki siinä olevat komponentit näytetään tai piilotetaan. Yksittäisten komponenttien näyttämisen tai piilottamisen sijaan voit piilottaa ja näyttää paneelin ja kaikki siinä olevat komponentit yhdellä komennolla. Tässä esimerkissä käytetään seuraavia komponentteja: [[TButton/fi|TButton]] ja [[TShape/fi|TShape]]
6+
7+### Koodin ohjelmointi
8+
9+- Luo uusi tyhjä [[Graphical User Interface/fi|GUI-sovellus]] [[TForm/fi|lomakkeelle]] TForm1
10+- Luo lomakkeelle OnCreate-tapahtumakäsittelijä napsauttamalla lomaketta, käyttämällä komponenttimuokkaimen tapahtumat-välilehteä, valitsemalla OnCreate-tapahtuma ja napsauttamalla painiketta \[...\] tai kaksoisnapsauttamalla lomakkeen painiketta.
11+- Lisää seuraava ohjelmakoodi (Täydennä puuttuvat osat):
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+## Katso myös
85+
86+- [[doc:lcl/extctrls/tpanel.html|TPanel doc]]
87+- [[TBevel/fi|TBevel]]
88+- [[TFrame/fi|TFrame]]
89+- [[TFlowPanel/fi|TFlowPanel]]
90+
91+---
92+*From the Free Pascal wiki, page "TPanel/fi", as it stood on 2019-10-04 after a change by Djzepi, 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).*

Back to history