Is it possible to display a form through a MessageDialog? [closed]

2

With MessageDialog , I would like to create components (buttons) at runtime and set the size and text of the buttons of this MessageDialog .

In addition, I need to display some forms according to the button that is chosen in this MessageDialog .

Is it possible?

    
asked by anonymous 22.10.2015 / 19:38

1 answer

3

Yes it is possible, it follows example:

procedure TForm1.Button1Click(Sender: TObject);
var
 i: Integer;
 f: Tform;
 clicado : Integer;
begin
  f:= createmessagedialog('Deseja Abrir outro Formulário?',
   mtconfirmation,[mbyes,mbno,mbok,mbcancel]);

    try
      for i:=0 to f.componentCount -1 do
       if f.components[i] is tbutton then
        with tbutton(f.components[i]) do
         case modalresult of
           mryes   : caption := '&Sim';
           mrno    : caption := '&Não';
           mrok    : caption := '&Certo';
           mrcancel: caption := '&Errado';
         end;
        f.caption := 'Opções'; //Caption da Janelinha

        //Aqui passamos o Código de qual o botão clicado
        clicado := f.showmodal;
       finally
        f.free;
       end;

    if clicado = 6 then
    begin
      //Aqui você chama o formulário
    end;

end;

Name of available buttons and their codes:

mrNone = 0; mrOk = 1; mCycel = 2; mrAbort = 3; mrRetry = 4; mIgnore = 5; mrYes = 6; mNoO = 7; mClCl 2 = 8; mrAll = 12; mNoToAll = 13; mrYesToAll = 14;

    
23.10.2015 / 00:44