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;
delphi
|
show 4 more comments
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;
delphi
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 withFormStyle=fsNormal
andVisible=False
by default (at design-time), and then manually switch it toFormStyle=fsMDIChild
andVisible=True
when it is not being shown modally.
– Remy Lebeau
Nov 9 at 18:13
|
show 4 more comments
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;
delphi
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
delphi
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 withFormStyle=fsNormal
andVisible=False
by default (at design-time), and then manually switch it toFormStyle=fsMDIChild
andVisible=True
when it is not being shown modally.
– Remy Lebeau
Nov 9 at 18:13
|
show 4 more comments
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 withFormStyle=fsNormal
andVisible=False
by default (at design-time), and then manually switch it toFormStyle=fsMDIChild
andVisible=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
|
show 4 more comments
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();
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
add a comment |
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();
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
add a comment |
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();
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
add a comment |
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();
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();
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
andVisible=False
by default (at design-time), and then manually switch it toFormStyle=fsMDIChild
andVisible=True
when it is not being shown modally.– Remy Lebeau
Nov 9 at 18:13