Is it possible to display a form through a Messagedialog?

Asked

Viewed 138 times

2

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

Besides, I need to show you some Forms according to the button chosen in this MessageDialog.

It is possible?

  • 1

    Can you explain and contextualize it better? The text of the question is quite confused and this question is already with 3 votes to close as "is not clear enough" and "too wide". And none of these closing vows are mine.

  • 1

    I think it’s pretty clear, since the friend down there has perfectly attended to what I wanted.

1 answer

3


Yes it is possible, follow 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 the available buttons and their respective Codes:

mrNone = 0; mrOk = 1; mrCancel = 2; mrAbort = 3; mrRetry = 4; mrIgnore = 5; mrYes = 6; mrNo = 7; mrClose = 8; mrAll = 12; mrNoToAll = 13; mrYesToAll = 14;

  • It would be possible to increase the size of buttons?

  • Their size is default VCL, can increase but the level for this already another subject! What you can do is create a custom window, and give Showmodal in it, getting just like a Messagebox, so yes you can put the buttons of the size you want among other customizations!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.