1
1

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 > debug / testing > 名前をデフォルトから変更していないコンポーネントの明示

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

http://qiita.com/7of9/items/59784e3398b8a966fa4b
の派生品。

コンポーネントを作成して、名前を変更していないTComboBoxを明示する。

Unit1.cpp
void __fastcall TForm1::debug_showDefaultNameTCombobox()
{

	TComponent *ptarget;
	for(int idx = 0; idx < ComponentCount; idx++) {
		ptarget = this->Components[idx];
		if (dynamic_cast<TComboBox *>(ptarget) == NULL) {
			continue;
		}

		TComboBox *cbPtr = (TComboBox *)ptarget;
		if (cbPtr->Name.Pos(L"ComboBox") > 0) {
			cbPtr->Items->CommaText = "Default_name";
			cbPtr->ItemIndex = 0;
		}
	}
}

結果

qiita.png

IDEの「構造」から探すこともできるが、こちらの方が早い。

v0.2

(追記 2016/11/07)

TCheckBox,TColorBox,TEditにも対応した。
未設定はVisible=falseとしてみた。

Unit1.cpp
void __fastcall TPDF_options::debug_showDefaultNameTCombobox()
{

    TComponent *ptarget;
	for(int idx = 0; idx < ComponentCount; idx++) {
        ptarget = this->Components[idx];
		if (dynamic_cast<TComboBox *>(ptarget) != NULL) {
			TComboBox *cbPtr = (TComboBox *)ptarget;
			if (cbPtr->Name.Pos(L"ComboBox") > 0) {
				cbPtr->Items->CommaText = "Default_name";
				cbPtr->ItemIndex = 0;
			}
		}

		if (dynamic_cast<TCheckBox *>(ptarget) != NULL) {
			TCheckBox *chkPtr = (TCheckBox *)ptarget;
			if (chkPtr->Name.Pos(L"CheckBox") > 0) {
				chkPtr->Visible = false;
			}
		}

		if (dynamic_cast<TColorBox *>(ptarget) != NULL) {
			TColorBox *clrPtr = (TColorBox *)ptarget;
			if (clrPtr->Name.Pos(L"ColorBox") > 0) {
				clrPtr->Visible = false;
			}
		}

		if (dynamic_cast<TEdit *>(ptarget) != NULL) {
			TEdit *edPtr = (TEdit *)ptarget;
			if (edPtr->Name.Pos(L"Edit") > 0) {
				edPtr->Visible = false;
			}
		}
	}
}

これで作業が中断となっても、再開時にすぐに続きが行える。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?