LoginSignup
0
0

More than 5 years have passed since last update.

c++ builder XE4, 10.2 Tokyo > キャプションに複数文字列のsuffixを追加する

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

アプリのキャプションに複数文字列のsuffixを追加したい。

例として"Test 1 B C"という文字列を追加したい。

実行時引数を使う。

Unit1.cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
    String mark = L"/caption=";

    for (int i=1; i<=ParamCount(); i++) {
        if (LowerCase(ParamStr(i)).Pos(mark) > 0) {
            String suffix = ParamStr(i).Delete(1,mark.Length());  // e.g. "/caption=Test_1_B_C"

            // 複数個の文字列を受けるためにいったん"_"付きで受けたものを"_"を消して使う
            suffix = StringReplace(suffix, L"_", L" ", TReplaceFlags()<<rfReplaceAll);

            String caption = L"Mysoftware";
            caption = caption + L" / " + suffix;
            this->Caption = caption;
        }
    }
}
//---------------------------------------------------------------------------

結果
qiita.png

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