Bring modeless form with WindowState=wsNormal behind MdiChild? - delphi

Is it possible to show a modeless "wsNormal" WindowsState form behind a MDIChild form? I want to create a NOTE form which is always behind other forms (but always in front of the MDI form), unless you bring it to the front. E.g when you click on it.

That's technically impossible for window that is not an child of the MDI container.
The MDI children are child windows of the MDI container which is a child of the main form. If a window is in front of the main form, then it is in front of the MDI children. If it is behind the main form, then it is behind the MDI children.

Normally no, MDI parent is the root parent of MDI childs, you're either below the MDI parent or above. But you can set the parent of your top-level form to be the MDICLIENT.
I wouldn't suggest this approach as it possibly would have complications (maybe(?) you can achieve the same effect by tweaking some other MDI client class). But if you want to try what it would look like create a new "MDI Application" project and change the code that runs from the Help->About menu item to:
procedure TMainForm.HelpAbout1Execute(Sender: TObject);
begin
// AboutBox.ShowModal;
windows.SetParent(AboutBox.Handle, ClientHandle);
AboutBox.Show;
SetWindowPos(AboutBox.Handle, HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOSIZE or SWP_NOMOVE);
end;

Related

MDIChild Form always behind ScrollBox

Based in this my working code, now i need of a ScrollBox component and a Image component inside he. Eg:
The problem now is the ScrollBox. The MDIChild Form always stays behind, you can test, changing ScrollBox Align (None/Client) property.
Then what is need to MDIChild Form stay above of ScrollBox?
The MDI client window that hosts the MDI child forms is the bottom most window of the MDIForm's content. You can't make MDI child forms appear on top of anything else, because literally everything else placed on the MDIForm is on top of the MDI client window and thus on top of the child forms.

Frame on main form with FormStyle = fsMDIForm

Is there a way to show MDI child forms (FormStyle = fsMDIChild) on the main form that has a frame with Align = alClient?
Creating a frame on the main form:
Frame := TfrCalendar.Create(Self);
Frame.Parent := Self;
Creating MDI child form on the main form:
if Assigned(FMDIRef)
then
FMDIRef.BringToFront
else begin
FMDIRef := TFReference.Create(Application);
FMDIRef.Show;
end;
After this, the child form is not visible. If you do not create a frame, the form is visible. If you first show the child form, and then create a frame on the main form, then the child form becomes invisible again.
The issue here is that your frame is competing for space with the MDI client window. The MDI client window is the window which is parent to the MDI child windows.
In your scenario the frame consumes all remaining client area inside the main window, thus leaving no space for the MDI client window.
What you are attempting is not possible. The MDI client window has to go somewhere, and you must leave it some room.
Depending on what your actual goal is, different solutions are available:
If the frame is intended to be visible always, then use alTop. The remaining space below it will be available to the MDI client window.
If you wish to show an image on the MDI client window to act as a background, refer to my answer here: https://stackoverflow.com/a/15137740/505088

Handle Needed For Firemonkey

How can i set the handle needed property for a form in firemonkey. In normal delphi I use to create forms inside other components at run time. IE:
Form1 := TForm1.Create(Panel1);
Form1.Parent := Panel1;
Form1.HandleNeeded;
But now in Firemonkey there are no Handles per say. So is there another way i can do this.
It is pretty essential that it has the parent Panel1 as the form has to only show in panel1 and no where else on the screen
In FMX if you want one form to be displayed inside another:
On the child form, add any controls inside a container (e.g. a TLayout). Create the child form. Set the Parent property of the TLayout (etc.) to the parent form (or, more probably a container on the parent form so you can set the child TLayout's alignment to alClient).
Thats what i am trying, but the form still apears as an independet form. not in the layout:
TNewLogin:=TFrmLogin.Create(Self);
TNewLogin.Parent:=Layout1;
TNewLogin.Show;

Delphi - child forms have frame of parent

I have a delphi application with multiple forms. Initially I had tried a setup where each newly opened form was a frame and the "parent" of this form (whichever called to open the form) was hidden as the child was shown with the child being resized and relocated to give a seamless effect of having one window, when the child is closed the parent is relocated and again made visible. All forms have a bsSingle border style for the Windows title block.
This approach worked well for positioning however the issue I have is a noticeable flicker as the parent form is closed and the child opened, and as there is a small time period where no form is opened the icon/tray on the start bar would shift around and itself become hidden and visible.
Does anybody have any advice on solving this problem? I thought perhaps if I only had one form with the border within the application and opened each new form within this border it would work better - though I am unsure how exactly to do this.
Any help is much appreciated.
It is easy to make one form appear as a child inside another. Create a new form which will contain and create your other forms:
procedure TMainForm.FormCreate(Sender: TObject);
var
F : TForm;
begin
F := TOneOfYourChildForms.Create(Self);
F.Parent := Self;
F.Show();
end;
Create both your child forms similar to this, then just do Show on the one you want to display and Hide on the other. Set BorderStyle to bsNone on the child forms to remove the caption. Turn off Auto-Create on your forms in project settings if you create them yourself like this instead.
I've had success with this design, and I think it helped to have the contents of the "main form" within a TFrame as well. When you want to show the main form, you would just perform a frame swap.

Duplicate ControlBox

I have inherited an application that was started as an MDI program, but the necessary background work was never put in place to fully support MDI. I'm trying to build in just enough MDI support to make the application look good and work properly as an SDI application.
Here's what I am observing, and I don't know how this is happening or how to fix it.
The MDIchild form's border is shown above the MDIparent form's menu strip.
The MDIchild form has two icons in the upper left.
The MDIchild form has two ControlBoxes in the upper right.
Any ideas why this would be?
I'd be really happy if the MDIChild window border (including the icons and control boxes) was removed entirely.
Thanks,
SH
I created the child form but showed it in normal state instead of maximized. It's as if showing the parent form in the same process as the maximized child form caused the form to be constructed out of order. My code looked something like this...
frmChild.WindowState = FormWindowState.Normal
frmParent.Show() 'frmChild.Show called within form_load of parent
frmChild.WindowState = FormWindowState.Maximized
And yes, I set the Child window's FormBorderStyle to None, but like I said, I didn't want an MDI application.
I think this must be a bug in Visual Studio. For so many people to have difficulty with it, it can't be right.
I found:
Call Show() on your MDI form before setting the WindowState property on your child form to get rid of the multiple control boxes.
Do not set the WindowState to Maximized in the designer -- do it in code after you've shown the parent.

Resources