LoginSignup
0
0

More than 5 years have passed since last update.

C++ Builder XE4, 10.2 Tokyo > TControl.Parent プロパティを指定したコンポーネント > Parentがdeleteされた時に自身もdeleteされる | TWinControl.Destroyでの実装

Last updated at Posted at 2018-12-11
動作環境
C++ Builder XE4
Rad Studio 10.2 Tokyo

疑問点

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    TPanel *pnlptr = new TPanel(/*AOwner=*/this);
    TLabel *lblptr = new TLabel(/*AOwner=*/this);
    lblptr->Parent = pnlptr;

    // some processing

    //delete lblptr;
    delete pnlptr;
}

上記の場合、lblptrは解放されるのかどうか?

関連

C++ Builder version 2009の情報

Note: The Parent property declared in TControl is similar to the Owner property declared in TComponent, in that the Parent of a control frees the control just as the Owner of a component frees that Component.

StackOverflowへの質問

解放される
という回答を得た。

I appreciate it, Remy Lebeau.

調べ方 (How to search)

今回はStackOverflowで質問をした。
その回答ではTWinControl.Destroyのソースとともに説明を受けた。

自分で調べる時はTWinControl.Destroyのコードを見ればいいという知見を得た。

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