Delphi MDIChild form flashes when opening in modal mode











up vote
-2
down vote

favorite












I have a MDIChild form that I open as follows:



Application.CreateForm (TForm1, Form1);


exemple MDIChild form class



unit Unit1;  
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
end.


but sometimes I need this form in modal ... with some tips I adapted my code as follows to open it in modal mode:



Application.CreateForm (TForm1, Form1); 
Form1.FormStyle: = fsNormal;
Form1.Visible: = False;
Form1.Position: = poMainFormCenter;
Form1.ShowModal;


that way it works, but it blinks until it shows on the screen ..



I would like to know if there is any way to not flash / show the form until you reach the Form1.ShowModal call;










share|improve this question
























  • Please provide Minimal, Complete, and Verifiable example
    – David Heffernan
    Nov 9 at 15:20










  • No, switching form style from fsMdiChild to fsNormal triggers the window of the form to be recreated. Since your form is already visible (being an mdi child) it blinks. You have to adapt something different or change your design.
    – Sertac Akyuz
    Nov 9 at 15:27








  • 1




    Why do you first change the style and then the visibility? I'd make the form hidden by default, create it, change the style to whichever you need, lastly show(modal) it.
    – GolezTrol
    Nov 9 at 15:46










  • @GolezTrol i'll try this..
    – Felipe Sachetti
    Nov 9 at 15:54






  • 1




    For those that don't speak Portuguese, the solution proposed is essentially to create the Form with FormStyle=fsNormal and Visible=False by default (at design-time), and then manually switch it to FormStyle=fsMDIChild and Visible=True when it is not being shown modally.
    – Remy Lebeau
    Nov 9 at 18:13

















up vote
-2
down vote

favorite












I have a MDIChild form that I open as follows:



Application.CreateForm (TForm1, Form1);


exemple MDIChild form class



unit Unit1;  
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
end.


but sometimes I need this form in modal ... with some tips I adapted my code as follows to open it in modal mode:



Application.CreateForm (TForm1, Form1); 
Form1.FormStyle: = fsNormal;
Form1.Visible: = False;
Form1.Position: = poMainFormCenter;
Form1.ShowModal;


that way it works, but it blinks until it shows on the screen ..



I would like to know if there is any way to not flash / show the form until you reach the Form1.ShowModal call;










share|improve this question
























  • Please provide Minimal, Complete, and Verifiable example
    – David Heffernan
    Nov 9 at 15:20










  • No, switching form style from fsMdiChild to fsNormal triggers the window of the form to be recreated. Since your form is already visible (being an mdi child) it blinks. You have to adapt something different or change your design.
    – Sertac Akyuz
    Nov 9 at 15:27








  • 1




    Why do you first change the style and then the visibility? I'd make the form hidden by default, create it, change the style to whichever you need, lastly show(modal) it.
    – GolezTrol
    Nov 9 at 15:46










  • @GolezTrol i'll try this..
    – Felipe Sachetti
    Nov 9 at 15:54






  • 1




    For those that don't speak Portuguese, the solution proposed is essentially to create the Form with FormStyle=fsNormal and Visible=False by default (at design-time), and then manually switch it to FormStyle=fsMDIChild and Visible=True when it is not being shown modally.
    – Remy Lebeau
    Nov 9 at 18:13















up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











I have a MDIChild form that I open as follows:



Application.CreateForm (TForm1, Form1);


exemple MDIChild form class



unit Unit1;  
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
end.


but sometimes I need this form in modal ... with some tips I adapted my code as follows to open it in modal mode:



Application.CreateForm (TForm1, Form1); 
Form1.FormStyle: = fsNormal;
Form1.Visible: = False;
Form1.Position: = poMainFormCenter;
Form1.ShowModal;


that way it works, but it blinks until it shows on the screen ..



I would like to know if there is any way to not flash / show the form until you reach the Form1.ShowModal call;










share|improve this question















I have a MDIChild form that I open as follows:



Application.CreateForm (TForm1, Form1);


exemple MDIChild form class



unit Unit1;  
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
end.


but sometimes I need this form in modal ... with some tips I adapted my code as follows to open it in modal mode:



Application.CreateForm (TForm1, Form1); 
Form1.FormStyle: = fsNormal;
Form1.Visible: = False;
Form1.Position: = poMainFormCenter;
Form1.ShowModal;


that way it works, but it blinks until it shows on the screen ..



I would like to know if there is any way to not flash / show the form until you reach the Form1.ShowModal call;







delphi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 15:37









GolezTrol

97.1k9129171




97.1k9129171










asked Nov 9 at 15:13









Felipe Sachetti

1716




1716












  • Please provide Minimal, Complete, and Verifiable example
    – David Heffernan
    Nov 9 at 15:20










  • No, switching form style from fsMdiChild to fsNormal triggers the window of the form to be recreated. Since your form is already visible (being an mdi child) it blinks. You have to adapt something different or change your design.
    – Sertac Akyuz
    Nov 9 at 15:27








  • 1




    Why do you first change the style and then the visibility? I'd make the form hidden by default, create it, change the style to whichever you need, lastly show(modal) it.
    – GolezTrol
    Nov 9 at 15:46










  • @GolezTrol i'll try this..
    – Felipe Sachetti
    Nov 9 at 15:54






  • 1




    For those that don't speak Portuguese, the solution proposed is essentially to create the Form with FormStyle=fsNormal and Visible=False by default (at design-time), and then manually switch it to FormStyle=fsMDIChild and Visible=True when it is not being shown modally.
    – Remy Lebeau
    Nov 9 at 18:13




















  • Please provide Minimal, Complete, and Verifiable example
    – David Heffernan
    Nov 9 at 15:20










  • No, switching form style from fsMdiChild to fsNormal triggers the window of the form to be recreated. Since your form is already visible (being an mdi child) it blinks. You have to adapt something different or change your design.
    – Sertac Akyuz
    Nov 9 at 15:27








  • 1




    Why do you first change the style and then the visibility? I'd make the form hidden by default, create it, change the style to whichever you need, lastly show(modal) it.
    – GolezTrol
    Nov 9 at 15:46










  • @GolezTrol i'll try this..
    – Felipe Sachetti
    Nov 9 at 15:54






  • 1




    For those that don't speak Portuguese, the solution proposed is essentially to create the Form with FormStyle=fsNormal and Visible=False by default (at design-time), and then manually switch it to FormStyle=fsMDIChild and Visible=True when it is not being shown modally.
    – Remy Lebeau
    Nov 9 at 18:13


















Please provide Minimal, Complete, and Verifiable example
– David Heffernan
Nov 9 at 15:20




Please provide Minimal, Complete, and Verifiable example
– David Heffernan
Nov 9 at 15:20












No, switching form style from fsMdiChild to fsNormal triggers the window of the form to be recreated. Since your form is already visible (being an mdi child) it blinks. You have to adapt something different or change your design.
– Sertac Akyuz
Nov 9 at 15:27






No, switching form style from fsMdiChild to fsNormal triggers the window of the form to be recreated. Since your form is already visible (being an mdi child) it blinks. You have to adapt something different or change your design.
– Sertac Akyuz
Nov 9 at 15:27






1




1




Why do you first change the style and then the visibility? I'd make the form hidden by default, create it, change the style to whichever you need, lastly show(modal) it.
– GolezTrol
Nov 9 at 15:46




Why do you first change the style and then the visibility? I'd make the form hidden by default, create it, change the style to whichever you need, lastly show(modal) it.
– GolezTrol
Nov 9 at 15:46












@GolezTrol i'll try this..
– Felipe Sachetti
Nov 9 at 15:54




@GolezTrol i'll try this..
– Felipe Sachetti
Nov 9 at 15:54




1




1




For those that don't speak Portuguese, the solution proposed is essentially to create the Form with FormStyle=fsNormal and Visible=False by default (at design-time), and then manually switch it to FormStyle=fsMDIChild and Visible=True when it is not being shown modally.
– Remy Lebeau
Nov 9 at 18:13






For those that don't speak Portuguese, the solution proposed is essentially to create the Form with FormStyle=fsNormal and Visible=False by default (at design-time), and then manually switch it to FormStyle=fsMDIChild and Visible=True when it is not being shown modally.
– Remy Lebeau
Nov 9 at 18:13














1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










type
TfrmManProduto = class(TForm)
public
constructor Create(AOwner: TComponent; isModal: Boolean); reintroduce;
end;

implemetation

TfrmManProduto.Create(AOwner: TComponent; isModal: Boolean);
begin
inherited Create(AOwner);

Position := poMainFormCenter;

if not (isModal) then
begin
FormStyle := fsMDIChild;
Visible := True;
end;
end;


Call MDIChild Style (Non-Modal)



frmManProduto := TfrmManProduto.Create(Application, False);


Call Normal Style (Modal)



frmManProduto := TfrmManProduto.Create(Application, True);
frmManProduto.ShowModal();





share|improve this answer























  • I don't know if it's the best solution, but it's at least pretty clear. You could even choose to pass the formstyle instead of a boolean, so the code is even more explicit, and you have the possibility to use the other styles as well.
    – GolezTrol
    Nov 10 at 21:29










  • @GolezTrol Great idea, pass the formstyle, even not having this need now, is functional for future needs.
    – Felipe Sachetti
    Nov 12 at 10:57













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228394%2fdelphi-mdichild-form-flashes-when-opening-in-modal-mode%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










type
TfrmManProduto = class(TForm)
public
constructor Create(AOwner: TComponent; isModal: Boolean); reintroduce;
end;

implemetation

TfrmManProduto.Create(AOwner: TComponent; isModal: Boolean);
begin
inherited Create(AOwner);

Position := poMainFormCenter;

if not (isModal) then
begin
FormStyle := fsMDIChild;
Visible := True;
end;
end;


Call MDIChild Style (Non-Modal)



frmManProduto := TfrmManProduto.Create(Application, False);


Call Normal Style (Modal)



frmManProduto := TfrmManProduto.Create(Application, True);
frmManProduto.ShowModal();





share|improve this answer























  • I don't know if it's the best solution, but it's at least pretty clear. You could even choose to pass the formstyle instead of a boolean, so the code is even more explicit, and you have the possibility to use the other styles as well.
    – GolezTrol
    Nov 10 at 21:29










  • @GolezTrol Great idea, pass the formstyle, even not having this need now, is functional for future needs.
    – Felipe Sachetti
    Nov 12 at 10:57

















up vote
0
down vote



accepted










type
TfrmManProduto = class(TForm)
public
constructor Create(AOwner: TComponent; isModal: Boolean); reintroduce;
end;

implemetation

TfrmManProduto.Create(AOwner: TComponent; isModal: Boolean);
begin
inherited Create(AOwner);

Position := poMainFormCenter;

if not (isModal) then
begin
FormStyle := fsMDIChild;
Visible := True;
end;
end;


Call MDIChild Style (Non-Modal)



frmManProduto := TfrmManProduto.Create(Application, False);


Call Normal Style (Modal)



frmManProduto := TfrmManProduto.Create(Application, True);
frmManProduto.ShowModal();





share|improve this answer























  • I don't know if it's the best solution, but it's at least pretty clear. You could even choose to pass the formstyle instead of a boolean, so the code is even more explicit, and you have the possibility to use the other styles as well.
    – GolezTrol
    Nov 10 at 21:29










  • @GolezTrol Great idea, pass the formstyle, even not having this need now, is functional for future needs.
    – Felipe Sachetti
    Nov 12 at 10:57















up vote
0
down vote



accepted







up vote
0
down vote



accepted






type
TfrmManProduto = class(TForm)
public
constructor Create(AOwner: TComponent; isModal: Boolean); reintroduce;
end;

implemetation

TfrmManProduto.Create(AOwner: TComponent; isModal: Boolean);
begin
inherited Create(AOwner);

Position := poMainFormCenter;

if not (isModal) then
begin
FormStyle := fsMDIChild;
Visible := True;
end;
end;


Call MDIChild Style (Non-Modal)



frmManProduto := TfrmManProduto.Create(Application, False);


Call Normal Style (Modal)



frmManProduto := TfrmManProduto.Create(Application, True);
frmManProduto.ShowModal();





share|improve this answer














type
TfrmManProduto = class(TForm)
public
constructor Create(AOwner: TComponent; isModal: Boolean); reintroduce;
end;

implemetation

TfrmManProduto.Create(AOwner: TComponent; isModal: Boolean);
begin
inherited Create(AOwner);

Position := poMainFormCenter;

if not (isModal) then
begin
FormStyle := fsMDIChild;
Visible := True;
end;
end;


Call MDIChild Style (Non-Modal)



frmManProduto := TfrmManProduto.Create(Application, False);


Call Normal Style (Modal)



frmManProduto := TfrmManProduto.Create(Application, True);
frmManProduto.ShowModal();






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 9 at 18:29

























answered Nov 9 at 18:23









Felipe Sachetti

1716




1716












  • I don't know if it's the best solution, but it's at least pretty clear. You could even choose to pass the formstyle instead of a boolean, so the code is even more explicit, and you have the possibility to use the other styles as well.
    – GolezTrol
    Nov 10 at 21:29










  • @GolezTrol Great idea, pass the formstyle, even not having this need now, is functional for future needs.
    – Felipe Sachetti
    Nov 12 at 10:57




















  • I don't know if it's the best solution, but it's at least pretty clear. You could even choose to pass the formstyle instead of a boolean, so the code is even more explicit, and you have the possibility to use the other styles as well.
    – GolezTrol
    Nov 10 at 21:29










  • @GolezTrol Great idea, pass the formstyle, even not having this need now, is functional for future needs.
    – Felipe Sachetti
    Nov 12 at 10:57


















I don't know if it's the best solution, but it's at least pretty clear. You could even choose to pass the formstyle instead of a boolean, so the code is even more explicit, and you have the possibility to use the other styles as well.
– GolezTrol
Nov 10 at 21:29




I don't know if it's the best solution, but it's at least pretty clear. You could even choose to pass the formstyle instead of a boolean, so the code is even more explicit, and you have the possibility to use the other styles as well.
– GolezTrol
Nov 10 at 21:29












@GolezTrol Great idea, pass the formstyle, even not having this need now, is functional for future needs.
– Felipe Sachetti
Nov 12 at 10:57






@GolezTrol Great idea, pass the formstyle, even not having this need now, is functional for future needs.
– Felipe Sachetti
Nov 12 at 10:57




















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228394%2fdelphi-mdichild-form-flashes-when-opening-in-modal-mode%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff