Generic dialog with custom captions for buttons
I know this issue have been up since before (ex. [Best way to show customized message dialogs][1]), but I still don't find what I want.

I started like this:

    class function TAttracsForm.MessageDlg(const aMsg: string; aDlgType: TMsgDlgType; Buttons: TMsgDlgButtons; aCaptions: array of String; aDefault: TMsgDlgBtn): TModalResult;
    var
      vDlg: TForm;
      i: Integer; 
    begin
      if aButtons.Count = aCaptions.Count then
      begin
        vDlg := CreateMessageDialog(aMsg, aDlgType, Buttons);
        try
          for i := 0 aCaptions.Count - 1 do
            TButton(vDlg.FindComponent(Buttons[i].Caption)).Caption := aCaptions[i]; 

          vDlg.Position := poDefaultPosOnly;
          Result := vDlg.ShowModal;
        finally
          vDlg.Free;
        end;
      end;
    end;

And the call would look like:

    if (MessageDlg('Really quit application ?', mtWarning, 
           [mbNo, mbCancel, mbYes], {'No save', 'Cancel', 'Save'}) = mrYes) then

 
But the above code of course don't compile. I don't know how to get one item of an set in the loop and how to get the total count of it in the beginning.

  [1]: http://stackoverflow.com/questions/1100073/what-is-the-best-way-in-delphi-to-show-customized-message-dialogs


Generic dialog with custom captions for buttons
===

I know this issue have been up since before (ex. [Best way to show customized message dialogs][1]), but I still don't find what I want.

I started like this:

    class function TAttracsForm.MessageDlg(const aMsg: string; aDlgType: TMsgDlgType; Buttons: TMsgDlgButtons; aCaptions: array of String; aDefault: TMsgDlgBtn): TModalResult;
    var
      vDlg: TForm;
      i: Integer; 
    begin
      if aButtons.Count = aCaptions.Count then
      begin
        vDlg := CreateMessageDialog(aMsg, aDlgType, Buttons);
        try
          for i := 0 aCaptions.Count - 1 do
            TButton(vDlg.FindComponent(Buttons[i].Caption)).Caption := aCaptions[i]; 

          vDlg.Position := poDefaultPosOnly;
          Result := vDlg.ShowModal;
        finally
          vDlg.Free;
        end;
      end;
    end;

And the call would look like:

    if (MessageDlg('Really quit application ?', mtWarning, 
           [mbNo, mbCancel, mbYes], {'No save', 'Cancel', 'Save'}) = mrYes) then

 
But the above code of course don't compile. I don't know how to get one item of an set in the loop and how to get the total count of it in the beginning.

  [1]: http://stackoverflow.com/questions/1100073/what-is-the-best-way-in-delphi-to-show-customized-message-dialogs

