c++c++buildervclc++builder-xe

How to change the Text of TMsgDlgButtons "Yes" and "No" Buttons in RAD Studio XE?


I want to change the Text of YES and NO buttons in a message box.

CModalWndManager::ShowMessageBox(AnsiString::LoadStr(IDS_NOT_SUPPORTED).c_str(), mtWarning, TMsgDlgButtons() << mbYes << mbNo, mbOK == mrYes);

Instead of YES, I want "Switch Mode", and for NO I want "Exit".

Is it possible to do this in RAD Studio XE?


Solution

  • http://bcbjournal.org/articles/vol4/0003/Making_marvelous_message_dialogs.htm

    TForm* Dlg = CreateMessageDialog(
        "Purge Warp Core?", mtConfirmation,
        TMsgDlgButtons() << mbYes << mbNo);
      TButton* yb = dynamic_cast<TButton *>
        (Dlg->FindComponent("Yes"));
      if (yb)
        yb->Caption = "Affirmative";
      TButton* nb = dynamic_cast<TButton *>
        (Dlg->FindComponent("No"));
      if (nb)
        nb->Caption = "Negative";
      int Rslt = Dlg->ShowModal();
      switch (Rslt) {
        case mrYes: ;// do "Yes" stuff
        case mrNo:  ;// do "No" stuff