1
I have a form MDIChild which I open as follows:
Application.CreateForm(TfrmManProduto, frmManProduto);
However, sometimes I need this form in modal... with some tips I adapted my code the following way to open it in modal mode:
Application.CreateForm(TfrmManProduto, frmManProduto);
frmManProduto.FormStyle := fsNormal;
frmManProduto.Visible := False;
frmManProduto.Position := poMainFormCenter;
frmManProduto.ShowModal;
That way it works, but it blinks until it shows on the screen.
I wonder if there is any way to not flash/show the form
until you reach the call frmManProduto.ShowModal;
good morning Roberto, I did as you passed, however, on the lines
frmManProduto.FormStyle := fsNormal;andVisible := True; generates Exception... tried to addinherited Create(AOwner);inside the constructor but it didn’t solve.. I think I’m missing something..– Felipe Sachetti
the
frmManProdutois still NIL in such situations, so does not accept amendments..– Felipe Sachetti
I changed it, now it should work, I put together the code kind of running and I didn’t realize I was referencing the variable, I had also forgotten the
inherited Create. But this corrected in the reply– Roberto de Campos
worked, but, in modal form he creates, shows on the screen but does not get modal... I tried to put a showmodal after creation but presents error, I tried to put after set
position, in this case it opens modal, but when closing it calls the form ONSHOW AND ONCREATE... I found it strange and could not figure out the reason...– Felipe Sachetti
The
ShowModalit has to be after theCreateand not during, I changed the answer, I put theShowModalfor example.– Roberto de Campos
I tested this way, and I get the message 'Cannot make a Visible modal window', in the call
frmManProduto := TfrmManProduto.Create(Application, True);it already creates the form and shows on the screen if I addfrmManProduto.ShowModal();he returns me the message above...– Felipe Sachetti
@Felipesachetti changed the answer, now I was able to test on my machine and it worked.
– Roberto de Campos
perfect... mto thanks Roberto, solve my problem...
– Felipe Sachetti