0

Well, I'll try to summarize. I have an MDI application that I would like that the forms "modal" stay overlapped only to forms "fsMDIChild" and not about any application. I did a search and did not get a solution through the ShowModal, it seems that there's no way to do. My question: is there any way to create a "type" form that it is the front of the forms within the MDI application and at the same time allow me to minimize the application?

Grotesque example: Various open registration screens and clicking the delete button of either the message "Really delete?". This confirmation message I would like to stay ahead of the registration screens, stay within the application area, as are the "fsMDIChild" and at the same time allow me to minimize the main form.

  • I'm not sure that you can make a modal MDI child, which is what you want – David Heffernan Apr 20 '15 at 12:44
  • Please include code samples of what you've already tried. – Elad Stern Apr 20 '15 at 12:45
  • In MainForm I call Application.CreateForm(TForm, Form); wherein Form formstyle fsMDIChild and visible true In Form I call Application.CreateForm(TForm1, Form1); Form1.Showmodal; wherein Form1 formstyle fsNormal and visible False – Felipe Sachetti Apr 20 '15 at 13:02
  • You can make your own form class derived from TForm which can lock forms to itself. Handling windows messages like Activate, Deactivate and positioning could do the job. Or you can do something like [this](http://stackoverflow.com/questions/594375/how-to-make-an-mdi-child-window-stay-on-top-of-its-siblings). – Tupel Apr 20 '15 at 13:42
  • I'm also wondering about the version tags. Don't add tags for the sake of it. Only to convey meaning. – David Heffernan Apr 20 '15 at 18:22

2 Answers2

1

As David Heffernan already sad you won't be able to use modal forms here, becouse purpose of the modal form is to prevent user from clicking on other parts of the application before the modal form execution is finished.

So how to solve your problem. I suggest you borow the idea from web design, specifically how Picture view windows are implemented.

Many web pages implement special cotnrol which alows you to view pictures in full resolution after clicking on Picture tumbnail that is originally visible on hte web page.

Now while clicking on such tumbnails seems to open a new window just big enough to contain the Picture (part of the webpage is still visible in background) that window size actually fills the whole webpage area.

This way control can easily advance to next Picture when you click on the visible image and closes itself when you click outside of visible window (transparent area).

So make something similar. Make a custom form for showing those messages. The form should fill up the entire client area used for showing the midi childs and stay on top of them (this can be achieved with changing of Z order).

I asume that achiving above won't be to difficult.

The only problem I could see is that it might be a bit harder to convince your new message form to also intercept the clicks on transparent areas which if my memory serves me corectly does not.

SilverWarior
  • 7,372
  • 2
  • 16
  • 22
0

One way may be to go latterally and prevent the other forms within the application from opening while the form you want to stay open is 'modal'.

To do this add a property such as

property IamModal : boolean read GetIamModal write SetIamModal; 

and a class or global variable to store the current modal form.

e.g.

var
  fCurrentModalForm : TForm;


TMyForm.GetIamModal : boolean;
begin
  Result := fCurrentModalForm = self;
end;

and

TMyForm.SetIamModal( Value : boolean );
begin
  if Value then
    fCurrentModalForm := self;
  else if fCurrentModalForm = self then
    fCurrentModalForm := nil;
end;

Then in the OnShow event of the other forms put something like

if assigned(fCurrentModalForm) and (fCurrentModelForm <> self) then
begin
  Beep;
  fCurrentModalForm.Focus := TRUE;
end;

Not sure if this would work in detail, but you get the idea.

Dsm
  • 5,870
  • 20
  • 24