0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

c++ builder XE4, 10.2 Tokyo > 階層構造のTPanelからTFormを取得する > TComponent *owner = Panel1_1_1->Owner;

Last updated at Posted at 2015-10-29
動作確認
C++ Builder XE4
Rad Studio 10.2 Tokyo Update 2 (追記: 2017/12/27)

Form314:TFormに以下の階層でTPanelがあるとする。

Panel1
..Panel1_1
....Panel1_1_1

Panel1_1_1などからForm314のポインタを取得するには
(Unityでいうところの .GetComponentInParent() )

Ownerというのでよさそう。

void __fastcall TForm314::Button1Click(TObject *Sender)
{
	TComponent *owner = Panel1->Owner;
	OutputDebugString(owner->Name.c_str());

	owner = Panel1_1->Owner;
	OutputDebugString(owner->Name.c_str());

	owner = Panel1_1_1->Owner;
	OutputDebugString(owner->Name.c_str());
}
結果
デバッグ出力: Form314プロセス Project1.exe
デバッグ出力: Form314プロセス Project1.exe
デバッグ出力: Form314プロセス Project1.exe
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?