I've gat a form A the is shown modally
On A there is a Print button, that will send whats displayed on A to be
printed.
My problem is, that after printing, A is no longer modal, and can be hidden
behind the main form of my program.
How can a modal form go un-modal without ModalResult is being set?
Something like this:
calling ShowA(true):
procedure TMainForm.ShowA(preview: boolean);
begin
if preview then begin
A.DrawOnFormCanvas;
A.ShowModal
end else begin
A.DrawOnPrinterCanvas;
A.PrintMe
end
end;
procedure TA.PrintButtonClick
begin
MainForm.ShowA(false)
end;
After the print button is clicked, the form is not modal anymore.
Thanks for your help.
Jacob
> How can a modal form go un-modal without ModalResult is being set?
Bugs in the VCL regarding parent/child window relationships. Which version
of Delphi are you actually using?
Gambit
I use Delphi 5 !
One good reason to upgrade?
Cheers
Jacob
> Hi -
>
> I've gat a form A the is shown modally
>
> On A there is a Print button, that will send whats displayed on A to
> be printed.
>
> My problem is, that after printing, A is no longer modal, and can be
> hidden behind the main form of my program.
>
> How can a modal form go un-modal without ModalResult is being set?
You can get this if you
a) use an older version of Delphi that does not support the PopupMode
property on forms.
b) use a version that supports this property but failed to set it to
pmAuto for the modal form.
c) run on XP or Vista and the printing takes long enough to make the
OS believe that the program as hung itself (since it does not process
messages in its GUI thread anymore). That makes the "window ghosting"
feature cut in and that messes up the relative Z-order of windows in
your program and can also make disabled windows come up enabled when
the OS detects that the program has started processing messages again
and thus destroys the ghost window.
--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
There are a lot of good reasons to upgrade, but you can fix this
problem in older Delphi versions by overriding the CreateParams method
of the modal form(s). One way to do it is this:
For your own modal forms: you have to create them with the caller form
as owner, e.g.
with tform3.create(self) do
try
showmodal;
finally
free;
end;
in a method of the caller form and you also override CreateParams for
the modal form:
procedure TForm3.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.Style := Params.Style or WS_POPUP;
Params.WndParent := TWinControl(Owner).handle;
end;