Sign in Join
Wiki copytemporary

Lazarus For Delphi Users/ja: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11この記事は、Lazarusに興味があり、すでにDelphiは知っている、という人々向けのものです。 この二つの違いについて記述しています。
22
33## DelphiからLazarusへ
44
55Lazarusは Delphiと同じく、RAD(Rapid Application Development、手早くアプリケーションを開発できる)ツールの一つです。ビジュアルなコンポーネントライブラリと、IDEがあります。Lazarusのコンポーネントライブラリ(LCL)はDelphiのVCLととても似ています。ほとんどのユニットと、クラスと、プロパティは、同じ名前と機能をもっています。これは、移植を簡単にします。しかし、Lazarusは'オープンソースのDelphiクローン'ではありません。ですから、100%の互換性を期待しないでください。
66
77### 最大の相違点は?
88
99Lazarusは完全にオープンソースで、プラットホームに対し独立しており、強力な[[Free Pascal|Free Pascalコンパイラ]](FPC)を使っています。FPCは15以上のプラットホームで動作します。しかし、すべてのパッケージやライブラリが移植されているわけではありません。ですから、Lazarusは現在のところLinux,FreeBSD,MaxOSX、そしてWin32上で動作します。(訳注:いくつかのPDAでも暫定的な動作はします。日本語に関する処理の改善に、これから皆さんの力を必要としています。)
1010
1111**Lazarusは、この文章がまたそうであるように、常に未完です。私たちはいつでも、新しい開発者、パッケージ管理者、移植者、ドキュメントの執筆者を募っています。**
1212
1313### Delphi のプロジェクトを Lazarus 用に変換するためにまず必要なこと
1414
1515Lazarus を起動し、 **Tools** メニューから **Convert Delphi Project to Lazarus Project** を選んで下さい。これで全てが解決する訳ではありませんが、大変役立つはずです。Lazarus IDE の変換ツールは一般に一方通行であり、逆の変換はできないことに注意して下さい。プロジェクトを Delphi でも Lazarus でもコンパイルできるように Delphi との互換性を維持する必要がある場合は、Lazarus IDEではなく [XDev Toolkit](http://wiki.lazarus.freepascal.org/XDev_Toolkit) の利用を考えて下さい。
1616
1717### ユニコードのサポート
1818
19192007バージョンまでの Delphi はユニコードをサポートせず、Windows が利用していた ANSI エンコーディングを採用していました。2008バージョン以降の Delphi はユニコードをサポートするようになり、UTF-16 を用いて文字列をエンコードしています。
2020
2121一方、Lazarus は UTF-8 を用いたユニコードサポートを始めました。詳しくは [[LCL Unicode Support]] を御読みください。.
2222
2323## Delphi IDE から Lazarus IDE へ
2424
2525### プロジェクト
2626
2727Delphiアプリケーションのメインのファイルは .dprファイルです。Lazarusにおいては、.lpiファイルです(=Lazarus Project Information)。 .dprファイルはメインのソースプログラムであり、DelphiのIDEはコンパイラスイッチやユニットなどの情報の一部を入れます(訳注:すべてではない。オプションファイルなどがある)。Lazarusのアプリケーションもメインのソースファイルを.lprファイルに入れます。しかし、そのほかのすべての情報をも入れます。ですから、.lpiファイルはとても重要です。
2828
2929例: Delphiはユニットへのパスを.dprファイルに入れます。たとえば、unit1 in 'path/Unit1.pas'というふうにいれます。このinでパスを指定する方法はDelphi独特であり(Pascalの文法ではないので)、Lazarus IDEは読むことができないので、こういう方法をつかわないでください。かわりに、コンパイラオプションで、ユニットパスを指定してください。
3030
3131Delphiはコンパイラオプションを.dprファイルに埋め込みます。たとえば、{\$APPTYPE CONSOLE}.というふうにいれます。Lazarus IDEでは、これらは無視されますので、使わないで下さい。かわりに、コンパイラオプションを使ってください。
3232
3333(訳注:DelphiのdprファイルはPascalの仕様+独自の部分が結構多いですが、Free Pascal Compiler上のLazarusとしては、Free Pascalに特殊な言語拡張をなるべく行わず、純粋にFree Pascal上に実現できるような方法がとられています。Delphiのようにコンパイラオプションを至る所に定義できるのは、便利でもある一方、スキャンしていかないと、有効か無効かが分からず、バグや全体のみとおしが悪くなる両刃の剣といえますので、訳者は良い仕様だと思います。)
3434
3535ひとつ重要なルールがあります。それは、*常に*プロジェクトは存在するということです(訳注:IDEが起動している最中に、ということでしょう)。 現在のプロジェクトを"close"する方法は、lazarusを終了するか、他のプロジェクトを開くしかありません。 これは、lazarusのプロジェクトはセッションとしての役割があるからです。これは、現在のエディタの設定が、.lpiファイルに記録され、そのプロジェクトを開いたときに再開できるようになっています。たとえば、あなたがアプリケーションをデバッグしていて、多くのブレークポイントやブックマークを開いていたとしましょう。あなたは、いつでもプロジェクトを保存することができ、lazarusを終了したり、他のプロジェクトを開くことができます。その、デバッグ中に保存したプロジェクトを開くと(たとえ他のコンピュータで開いたとしても)、ブレークポイント、ブックマーク、開いていたファイル、カーソル位置、ジャンプヒストリ、などといったものが、復元できます。
3636
3737### ソースエディタ
3838
3939ほとんどすべてのキーとショートカットが、enviroment -\> editor options-\>key mappingsで定義可能です。 LazarusのIDEには、ソースのための沢山のツールがあります。それらの多くは、Delphiと見た目も似ており、よくにた働きをします。しかし、一つの重要な相違点があります。すなわち、Lazarusはコード情報を取るために、コンパイラを利用しない、ということです。ソースコードを直接解析します。こうすることで、沢山の重要な利点があります。
4040
4141ソースエディタは、"comments"と一緒に動作します。Delphiにおいては、ソース中のコメントは、コードの間の場所にあるものにすぎません。自動でコードが挿入されても、特別な働きはしないので、すでに入れたコメントは迷子になってしまうかもしれません。Lazarusでは、コメントの中のコードでさえ、宣言を見つけることができます。 これは、完璧に信頼できるものではないかもしれませんが、よく役に立ってます。新しいコードが挿入されると、IDEは発見的な方法を使ってコメントとコードを結び付けます。たとえば、"c: char; // comment"という行は分割されることはありません。
4242
4343Delphiの"コード補完"(Ctrl+Space)機能は、Lazarusでは、"Identifier Completion"と呼ばれます。Lazarusにおいて、コード補完は、"自動的なクラス補完"(Delphiとおなじです)、"ローカル変数補完"、"イベント割り当て補完"のあわせた機能です。これらのすべては、Ctrl+Shift+Cで呼び出され、IDEは、カーソルの位置から、何をなすべきか決定します。
4444
4545#### ローカル変数補完の例
4646
4747ちょうど新しいメソッドを作り、"i:=3;"という命令を書いたとしましょう。
4848
49-`procedure TForm1.DoSomething;`\
50-`begin`\
51-`  i := 3;`\
52-`end;`
49+``` pascal
50+procedure TForm1.DoSomething;
51+begin
52+ i := 3;
53+end;
54+```
5355
5456識別子"i"の上にカーソルをおいて、Ctrl+Shift+Cを押すと、次のようになります。
5557
56-`procedure TForm1.DoSomething;`\
57-`var`\
58-`  i: Integer;`\
59-`begin`\
60-`  i := 3;`\
61-`end;`
58+``` pascal
59+procedure TForm1.DoSomething;
60+var
61+ i: Integer;
62+begin
63+ i := 3;
64+end;
65+```
6266
6367#### イベント割当補完の例
6468
6569オブジェクトインスペクタの良い機能のひとつに、自動的にメソッドを作ること、があります。ソースエディタでやってみてください。
6670
6771たとえば:
6872
69-`Button1.OnClick:=`
73+``` pascal
74+Button1.OnClick:=
75+```
7076
7177代入演算子":="の後で、Ctrl+Shift+Cを押してみてください。
7278
7379#### 手続呼出補完の例
7480
7581今 "DoSomething(Width);" という文を書き終えた所だとします:
7682
7783``` pascal
7884procedure SomeProcedure;
7985var
8086 Width: integer;
8187begin
8288 Width:=3;
8389 DoSomething(Width);
8490end;
8591```
8692
8793識別子 "DoSomething" の上にカーソルを置いて、Ctrl+Shift+C を押すと、こうなります:
8894
8995``` pascal
9096procedure DoSomething(aWidth: LongInt);
9197begin
9298
9399end;
94100
95101procedure SomeProcedure;
96102var
97103 Width: integer;
98104begin
99105 Width:=3;
100106 DoSomething(Width);
101107end;
102108```
103109
104110#### 語彙補完 Ctrl+W
105111
106112識別子補完と似ていますが、パスカルの識別子に対してではなく、すべての語彙に対して補完します。あなたが開いているすべてのファイルの中から、あなたがタイプし始めた文字が同じものの語彙をリストアップし、選択できます。
107113
108114#### インクルードファイルのサポート
109115
110116Delphiではインクルードファイルをサポートしていませんので(訳注:\$iがあるので、補完機能が、ということだろう)、多分、みなさんは多くのインクルードファイルを今までに作っていないかもしれません。しかし、インクルードファイルには、大きな利点があります。それは、IFDEFでソースコードを汚さずに、プラットホーム独立なコードを書けるということです。 Lazarusでは、メソッドジャンプ、クラス補完、宣言を見つける、など、すべての機能は、インクルードファイルに対しても働きます。 また、コーディング機能にいろんなオプションがあります。
111117
112118### デザイナ
113119
114120\- ガイドライン
115121
116122#### オブジェクト・インスペクタ
117123
118124DelphiとLazarusのIDEでは、オブジェクトインスペクタはコンポーネントプロパティを編集したり、イベントを設定したりするのに使われます。使い方に、いくつかの小さな違いがあります。
119125
1201261. Delphi5を起動すると、オブジェクトインスペクタのなかで、階層にしたがって伝統的なドロップダウンリストでオブジェクトを選択できるオブジェクトツリービューがあります。Lazarusでは、これは、オブジェクトインスペクタの一部にすぎません。デフォルトのドロップダウンリストのかわりに、右クリックで表示される"Show Component Tree"メニューを使うこともできます。
1211272. Delphiでは、空のイベントでダブルクリックすると、自動的にイベントを作成し、ソースエディターがその位置を開きます。Lazarusは右側にボタンがあり、ドロップダウンでイベントを作成することができます。
1221283. Delphiでは、つけられたイベント名は手で消さなくてはなりませんが、Lazarusでは、"(None)"をドロップダウンで選ぶことができます。
1231294. Eventと同じように、booleanのような標準的なプロパティをダブルクリックすることでは、値は変化しません。値を変えるには、ドロップダウンで選択する必要があります。そして、エディターフォームで結び付けられているものを開くには、editやdrop-downの右側にある'...'ボタンをクリックする必要があります。
124130
125131#### パッケージ
126132
127133LazarusはDelphiのパッケージをインストールして使うことはできますか?
128134
129135いいえ、なぜなら、それには、Delphiのコンパイラマジック(訳注:Pascalではない部分の特殊な文法)が必要だからです。
130136
131137私たちは、Lazarus向けに特別にパッケージを作りたいのですが?
132138
133139はい。新しくパッケージをつくり、パッケージソースディレクトリに保存してください。 通常は dpkファイルと同じディレクトリです。そして、LCLを必要とするパッケージとして加えて、最後に.pasファイルを加えてください。それを今すぐインストールしたり、プロジェクトで使うことができます。 LazarusとDelphiのパッケージで、いくつかの違いがありますので、lazarusのソース内のdocs/Packages.txtを読んでください。
134140
135141### VCL から LCL へ
136142
137143VCLとLCLは、ともに、高速なアプリケーション開発向けの、オブジェクト指向の階層的なコンポーネントのライブラリです。しかし、それらは同じではありません。 たとえば、VCLは多くの非ビジュアルなコンポーネントを含みます。一方、LCLは、[[Free Pascal|Free Pascalによって]]、多くの「ビジュアルでない」コンポーネント(データベースアクセスなど)が提供されていますので、ビジュアルなコンポーネントのみ、を提供しようとしています。 (訳注:データベースの表示については、ビジュアルである。そのなかで使われるデータベースアクセス自体はLCLコンポーネント内に統合されていると思われる)
138144
139145加えていうと、VCL等にある多くのコントロールが、LCLには存在しないかもしれませんし、同じようなコントロールが両方に存在する場合でも、それらはクローンではありません。 ですから、もし移植をするなら、アプリケーション、コンポーネント、およびコントロールのそれぞれで変更が必要です。
140146
141147次のことはDelphiユーザのために、DelphiとLazarusの主要な違いや、互換性のない所を、包み隠さずに明らかにしようとするものです。これは、主にD4でのVCL(D5,D6,D7も同様です)と、現在のCVSに、あるがままのLCLの違いをカバーしました。あなたがいつも使っているDelphiやLCLのバージョンに完全に一致しないかもしれません。もし、これらの記述が正確でないとすれば、他の皆さんの理解のために、ご自由に記述を加えたり、変更してください。
142148
143149#### TControl.Font/TControl.ParentFontについて
144150
145151VCLでは、コントロールにフォントのプロパティとして、ボールドやイタリック、特定のフォント名と等を使用し、通常はこの値がいつも子へと引き継がれていきます。 さらに、コントロールがいつもParentのフォントを確実にする継承するために、TControl.ParentFontプロパティを提供しています。 OSにウインドウの見え方の設定があるのですが、コントロールのプロパティが常時優先されるということを暗に決めてつけてしまっています。
146152
147153(訳注:Windowsで画面で大きい文字などが選択できるが、他のデスクトップではもっと多くのことが指定できるものがあるので、Delphiにおいてもシステムフォントを取得することが望ましい、とされる場合もあるが、きっちりデザインが難しくなる。)
148154
149155このフォントについての機能、解釈はLCLでは、異なっています。 現実にクロスプラットフォーム/クロスインタフェースであるLCLは、バランスのとれた手法を好んで採用しようとしています。LCLは、いつでも、どんなウィジェットでのネイティブのDesktop/ツールキットのApearance、Theme設定も使用しようとします。 例えば、テーマが、ボタンのための特定の字体を供給するGTKインタフェース、およびgtkを使用することがありますが、LCLボタンはいつもこのテーマに沿った字体を使用します。
150156
151157このことは、ほとんどのLCLコントロールはVCLで当たり前になっている、設計上のフォントなどの管理機能は持っていない、ということです。 しかし、もし、この仕様を変更したければ、使用されるインターフェースにかかわらず、この様に統一的に割り当てられたインタフェースに代わり、Canvasに独自で描画するカスタムコントロールを使うことができます。
152158
153159例えば太字や、特別な色の字体のLabelが必要な場合、代わりにTStaticTextを使用しなければなりません。 なぜなら、TLabelは特定のコントロールのインタフェースであり、すべてのインタフェースのネイティブなバージョンを供給するのであるならば、その大部分は、すべての環境が考慮されないかもしれない、デフォルトの設定が利用されるでしょう。
154160
155161#### ドラッグとドッキングの制御
156162
157163VCLでは、実行中に、例えば1個のパネルからコントロールをドラッグして、別のパネルにドッキングできるように、ほとんどのTWinControlからの派生コントロールは、ドラッグ、ドッキングを制御する機能が組み込まれています。
158164
159165この機能はLCLでは、現在、未完成であり、実装されていません。現在、設計の初期段階です。このタイプのふるまいが、同じような方法で、同等のレベルの互換性を維持するように、最終的には、サポートしてくれると思います。
160166
161167これは、現在、どんなControlも以下のTControlの機能、プロシージャ、プロパティを継承していない、使っていない、ということを意味します。
162168
163169``` pascal
164170Protected
165171 function GetDockEdge(MousePos: TPoint): TAlign;
166172 function GetDragImages: TDragImageList;
167173 function GetFloating: Boolean;
168174 function GetFloatingDockSiteClass: TWinControlClass;
169175 procedure DoEndDrag(Target:TObject); X, Y: Integer);
170176 procedure DockTrackNoTarget(Source: TDragDockObject; X, Y: Integer);
171177 procedure DoEndDock(Target: TObject; X, Y: Integer);
172178 procedure DoDock(NewDockSite: TWinControl; var ARect: TRect);
173179 procedure DoStartDock(var DragObject: TDragObject);
174180 procedure DragCanceled;
175181 procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState;
176182 var Accept: Boolean);
177183 procedure DoEndDrag(Target: TObject; X, Y: Integer);
178184 procedure DoStartDrag(var DragObject: TDragObject);
179185 procedure DrawDragDockImage(DragDockObject: TDragDockObject);
180186 procedure EraseDragDockImage(DragDockObject: TDragDockObject);
181187 procedure PositionDockRect(DragDockObject: TDragDockObject);
182188 procedure SetDragMode(Value: TDragMode);
183189 property DragKind: TDragKind;
184190 property DragCursor: TCursor;
185191 property DragMode: TDragMode;
186192 property OnDragDrop: TDragDropEvent;
187193 property OnDragOver: TDragOverEvent;
188194 property OnEndDock: TEndDragEvent;
189195 property OnEndDrag: TEndDragEvent;
190196 property OnStartDock: TStartDockEvent;
191197 property OnStartDrag: TStartDragEvent;
192198public
193199 function Dragging: Boolean;
194200 function ManualDock(NewDockSite: TWinControl; DropControl: TControl;
195201 ControlSide: TAlign): Boolean;
196202 function ManualFloat(ScreenPos: TRect): Boolean;
197203 function ReplaceDockedControl(Control: TControl; NewDockSite: TWinControl;
198204 DropControl: TControl; ControlSide: TAlign): Boolean;
199205 procedure BeginDrag(Immediate: Boolean; Threshold: Integer);
200206 procedure Dock(NewDockSite: TWinControl; ARect: TRect);
201207 procedure DragDrop(Source: TObject; X, Y: Integer);
202208 procedure EndDrag(Drop: Boolean);
203209 property DockOrientation: TDockOrientation;
204210 property Floating: Boolean;
205211 property FloatingDockSiteClass: TWinControlClass;
206212 property HostDockSite: TWinControl;
207213 property LRDockWidth: Integer;
208214 property TBDockHeight: Integer;
209215 property UndockHeight: Integer;
210216 property UndockWidth: Integer;
211217```
212218
213219that the following classes do not exist/are unusable -
214220
215221``` pascal
216222TDragImageList = class(TCustomImageList)
217223TDockZone = class
218224TDockTree = class(TInterfacedObject, IDockManager)
219225TDragObject = class(TObject)
220226TBaseDragControlObject = class(TDragObject)
221227TDragControlObject = class(TBaseDragControlObject)
222228TDragDockObject = class(TBaseDragControlObject)
223229```
224230
225231下記の関数も、利用できないか、互換性がありません。
226232
227233``` pascal
228234function FindDragTarget(const Pos: TPoint;
229235 AllowDisabled: Boolean) : TControl;
230236procedure CancelDrag;
231237function IsDragObject(sender: TObject): Boolean;
232238```
233239
234240#### TEdit、および、TCustomEditについて
235241
236242Editコントロールは、LCLもVCLと同等の機能をもっていますが、移植中に、いくつかの気をつけるべき点があります。
237243
2382441. GUIインターフェースでの制限で、TEdit.PasswordCharはすべてのインタフェースでは、まだ正常に機能しません。入力テキストを隠するために必要とする場合は、代わりに、TCustomEdit.EchoMode emPasswordを使用します。
2392452. ドラッグ、ドッキングイベントはまだ実装されていません。詳しくは、Control Dragging/Docking.
2402463. フォントプロパティは、GUIの統一性のためにたいてい無視されます。詳しくは、TControl.Font/TControl.ParentFont
241247
242248### (optional) TSplitter -\> TPairSplitter
243249
244250**Please Improve Me**
245251
246252There is now a TSplitter control in the LCL, so no need to convert it.
247253
248254Nevertheless, if you want, here it is explained:
249255
250256The following is loosely based on questions by Vincent Snijders on the mailing list, and responses by [Andrew Johnson](http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson):
251257
252258In the VCL, "Splitting" controls, that is a handle which can be dragged between two components to give one more or less space then the other, is accomplished by a TSplitter. This is often seen, for instance in the Delphi IDE between the docked Code Explorer and Source Viewer.
253259
254260The LCL provides its own Control called a TPairSplitter, which serves the same type of purpose, however it is not compatible, so "repairing" broken VCL code or Delphi DFM's will be necesary in the event of porting code, even though much is shared in common between the two.
255261
256262So what exactly are the differences?
257263
258264Well the biggest differences are a VCL TSplitter has no children, instead it is placed between two controls aligned properly, and allows resizing between them at runtime, regardless its own size. It must have two controls aligned on each size to do anything. A simple example would be form with a Left Aligned Panel, a left aligned Splitter, and a second client aligned panel. On run time you could then realign the size given each panel by dragging on the handle provided by this Splitter control.
259265
260266On the LCL hand however, a TPairSplitter is a special kind of control, with two panels, and it can only be usefull if the controls to split are on these panels, but it will still perform a split between those panel whether or not anything is on them. So following the prior example, you would have a form with a TPairSplitter aligned client, and a panel aligned client on its left side, and a panel aligned client on its right side.
261267
262268The other important difference is that in the VCl, since the TSplitter is its own TControl, then the position is kept relative to the other controls on resize, so for instance a client panel will grow while the other panels will not, thus the split position is relative to the alignment of the split controls,
263269
264270In the LCL since the side panels are separate then the TPairSplitter has a Position property which is absolute relative to top or left. so on resize the actual position does not change according to contents, so a callback must be set to ensure the ratio is kept on resize if this is important.
265271
266272For example if the Right side of a vertical split needs to have alClient like behaviour, you need to add a form resize callback which does something like :
267273
268-`PairSplitter.Position := PairSplitter.Width - PairSplitter.Position; `
274+``` pascal
275+PairSplitter.Position := PairSplitter.Width - PairSplitter.Position;
276+```
269277
270278So how can I convert existing code using TSplitter to the TPairSplitter?
271279
272280If the splitter and controls are created within an actual function(like form oncreate), conversion shouldn't be too difficult, primarily reorganize the code to create the controls in order of new hierarchy and set the parents of the child controls to split to the left/top and right/bottom portions of the PairSplitter. An example of the changes being -
273281
274282**VCL**
275283
276284**LCL**
277285
278286``` pascal
279287var
280288 BottomPanel: TPanel;
281289 VerticalSplitter: TSplitter;
282290 LeftPanel: TPanel;
283291 HorizontalSplitter: TSplitter;
284292 MainPanel: TPanel;
285293
286294begin
287295 BottomPanel:= TPanel.Create(Self);
288296 with (BottomPanel) do
289297 begin
290298 Parent:= Self;
291299 Height:= 75;
292300 Align:= alBottom;
293301 end;
294302
295303 VerticalSplitter:= TSplitter.Create(Self);
296304 with (VerticalSplitter) do
297305 begin
298306 Parent:= Self;
299307 Align:= alBottom;
300308 end;
301309
302310 HorizontalSplitter:= TSplitter.Create(Self);
303311 with (HorizontalSplitter) do
304312 begin
305313 Parent:= Self;
306314 align:= alLeft;
307315 end;
308316
309317 LeftPanel:= TPanel.Create(Self);
310318 with (LeftPanel) do
311319 begin
312320 Parent:= Self;
313321 Width:= 125;
314322 Align:= alLeft;
315323 end;
316324
317325 MainPanel:= TPanel.Create(Self);
318326 with (MainPanel) do
319327 begin
320328 Parent:= Self;
321329 Align:= alClient;
322330 Caption:= 'Hello';
323331 end;
324332end;
325333```
326334
327335``` pascal
328336var
329337 BottomPanel: TPanel;
330338 VerticalSplitter: TPairSplitter;
331339 LeftPanel: TPanel;
332340 HorizontalSplitter: TPairSplitter;
333341 MainPanel: TPanel;
334342
335343begin
336344 VerticalSplitter:= TPairSplitter.Create(Self);
337345 with (VerticalSplitter) do
338346 begin
339347 Parent:= Self;
340348 Align:= alClient;
341349 Width:= Self.Width;
342350 Height:= Self.Height;
343351 SplitterType:= pstVertical;
344352 Position:= Height - 75;
345353 Sides[0].Width:= Width;
346354 Sides[0].Height:= Position;
347355 end;
348356
349357 HorizontalSplitter:= TPairSplitter.Create(Self);
350358 with (HorizontalSplitter) do
351359 begin
352360 Parent:= VerticalSplitter.Sides[0];
353361 Width:= Self.Width;
354362 Height:= VerticalSplitter.Position;
355363 align:= alClient;
356364 SplitterType:= pstHorizontal;
357365 Position:= 125;
358366 end;
359367
360368 LeftPanel:= TPanel.Create(Self);
361369 with (LeftPanel) do
362370 begin
363371 Parent:= HorizontalSplitter.Sides[0];
364372 Align:= alClient;
365373 end;
366374
367375 MainPanel:= TPanel.Create(Self);
368376 with (MainPanel) do
369377 begin
370378 Parent:= HorizontalSplitter.Sides[1];
371379 Align:= alClient;
372380 Caption:= 'Hello';
373381 end;
374382
375383 BottomPanel:= TPanel.Create(Self);
376384 with (BottomPanel) do
377385 begin
378386 Parent:= VerticalSplitter.Sides[1];
379387 Align:= alClient;
380388 end;
381389end;
382390```
383391
384392So as you can see, farely consistant with most control hierarchy. And if you are familiar with DFM's, the changes needed for DFM-\>LFM conversion should be farely obvious from the above, as they are the same sort of changes in Parent/Owner etc.
385393
386394So the above example would be something like -
387395
388396**Delphi DFM**
389397
390398**(extraneous values removed)**
391399
392400**Lazarus LFM**
393401
394402**(most width, height, etc. removed)**
395403
396-``` pascal
404+``` lfm
397405object VerticalSplitter: TSplitter
398406 Height = 3
399407 Cursor = crVSplit
400408 Align = alBottom
401409end
402410object HorizontalSplitter: TSplitter
403411 Width = 3
404412 Align = alLeft
405413end
406414object BottomPanel: TPanel
407415 Height = 75
408416 Align = alBottom
409417end
410418object LeftPanel: TPanel
411419 Width = 125
412420 Align = alLeft
413421end
414422object MainPanel: TPanel
415423 Align = alClient
416424end
417425```
418426
419-``` pascal
427+``` lfm
420428object VerticalSplitter: TPairSplitter
421429 Align = alClient
422430 SplitterType = pstVertical
423431 Position = 225
424432 Height = 300
425433 Width = 400
426434 object Pairsplitterside1: TPairSplitterIde
427435 object HorizontalSplitter: TPairSplitter
428436 Align = alClient
429437 Position = 125
430438 object Pairsplitterside3: TPairSplitterIde
431439 Width = 125
432440 object LeftPanel: TPanel
433441 Align = alClient
434442 Width = 125
435443 end
436444 end
437445 object Pairsplitterside4: TPairSplitterIde
438446 object MainPanel: TPanel
439447 Align = alClient
440448 end
441449 end
442450 end
443451 end
444452 object Pairsplitterside2: TPairSplitterIde
445453 object BottomPanel: TPanel
446454 Align = alClient
447455 Height = 75
448456 end
449457 end
450458end
451459```
452460
453461### TCustomTreeView、およびTTreeViewについて
454462
455463VCLにもLCLにも、TCustomTreeView/TTreeViewのコンポーネントがあります。 ツリー構造化されたデータのリストで、複数のノードや、高度なセレクション、イメージリストなどの機能があります。 多くの機能は同等ですが、すべてのプロパティがまったくおなじではありません。主な相違点は以下です。
456464
457465**Incomplete list, also update to include TCustomTreeView Mark functions and protected methods**
458466
4594671. LCLには、 TCustomTreeView.Optionsがあります。これは、コントロールが変更されたときのふるまいと見かけのオプションです。これらのオプションは次の通りです。:
460468 - tvoAllowMultiselect - 複数のノードを選択できるモードです。eDelphi6のVCLのTCustomTreeView.MultiSelectと同等です。
461469 - tvoAutoExpand - ノードを自動展開します。TCustomTreeView.AutoExpandと同様です。
462470 - tvoAutoInsertMark - マウスが上を動くとドラッグのプレビューを更新します。
463471 - tvoAutoItemHeight - Itemの高さを自動的に調節します。
464472 - tvoHideSelection - 選択したItemをマークしません。
465473 - tvoHotTrack - ホットトラッキングをおこないます。TCustomTreeview.HotTrackを有効にするのと同等です。
466474 - tvoKeepCollapsedNodes - ノードを折畳んだりしたときに、子ノードを維持します。
467475 - tvoReadOnly - TreeviewをReadOnlyにします。TCustomTreeviewのReadOnlyを有効にするのと同等です。
468476 - tvoRightClickSelect - ノードをマウスの右クリックで選択状態にできるようにします。TCustomTreeView.RightClickSelectを有効にするのと同等です。
469477 - tvoRowSelect - 行選択を可能にします。TCustomTreeView.RowSelectを有効にするのと同等です。
470478 - tvoShowButtons - ボタンを表示します。TCustomTreeView.ShowButtonsを有効にするのと同等です。
471479 - tvoShowLines - ノードへの線を表示します。TCustomTreeView.ShowLinesを有効にするのと同等です。
472480 - tvoShowRoot - ルートノードを表示します。TCustomTreeView.ShowRootを有効にするのと同等です。
473481 - tvoShowSeparators - セパレータを表示します。
474482 - tvoToolTips - 個々のノードに、ツールチップを表示します。
4754832. LCLは次のプロパティを追加しました:
476484 - TCustomTreeView.OnSelectionChange イベント
477485 - TCustomTreeView.DefaultItems, アイテムのデフォルト設定のためのものです。
478486 - TCustomTreeView.ExpandSignType ノードの展開、折りたたみの際のサインを決定します。
4794873. LCLにあるほとんどのドラッグ、ドッキングイベントは動作しません。これについてのより詳細な情報は、前の「ドラッグとドッキングの制御」を見てください。
480488
481489### Messages / Events
482490
483491The order and frequency of messages and events (OnShow, OnActivate, OnEnter, ...) differ from the VCL and depend on the widgetset. The LCL provides a subset of WinAPI like messages to make porting of Delphi components easier, but almost all LCL messages work a little bit different than the VCL/WinAPI counterpart. The biggest part of Delphi code using WinAPI messages uses them, because the VCL lacks a feature or for speed reasons. Such things will seldom work the same under the LCL, so they must be checked manually. That's why LCL messages are called for example LM_SIZE instead of WM_SIZE (unit lmessages).
484492
485493**Note on handling of custom messages!** As of version 0.9.26 (December 2008), way of handling custom WinApi messages (e.g. WM_HOTKEY, WM_SYSCOMMAND) differs from the way of handling these messages in Delphi. At the moment you cannot handle them via **message** directive or via overriding of *WndProc* method of the form. The only way to handle them in the form is to hook Windows *windowproc* by yourself. Read more here: [[Win32/64 Interface|Processing non-user messages in your window]]
486494
487495## Original Contributors and changes
488496
489497This page has been converted from the epikwiki [version](http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusForDelphiUsers).
490498
491499- Initial import and formatting - VlxAdmin 9/26/2003
492500- Begin VCL -\> LCL with a section on TSplitter -\> TPairSplitter - [Andrew Johnson](http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson) 9/30/2003
493501- Add TControl.Font/TControl.ParentFont to VCL -\> LCL - [Andrew Johnson](http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson) 9/30/2003
494502- Update TEdit/TCustomEdit section in VCL -\> LCL - [Andrew Johnson](http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson) 10/1/2003
495503- Add Control Dragging/Docking to VCL -\> LCL - [Andrew Johnson](http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson) 10/1/2003
496504- Added "Object Inspector" to Delphi IDE -\> Lazarus IDE - [Andrew Johnson](http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson) 10/1/2003
497505- Added initial "TCustomTreeView/TTreeView" to VCL -\> LCL - [Andrew Johnson](http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson) 10/1/2003
498506- Added introduction to VCL -\> LCL - [Andrew Johnson](http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson) 10/1/2003
499507- Fixed some typos - Vincent 10/2/2003
500508- Fixed Typo User:Kirkpatc 20 May 2004
501509
502510## See Also
503511
504512[[Code Conversion Guide|Code Conversion Guide (from Delphi & Kylix)]]
505513
506514[[Compile With Delphi]]
507515
508516---
509517*From the Free Pascal wiki, page "Lazarus For Delphi Users/ja", as it stood on 2020-02-18 after a change by Trev, 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