Get active MDI child window - mdi

How to get active child frame from main frame?

MDIGetActive method gets you the HWND you need.

Related

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

Can my TControl be notified when its parent form is shown (DoShow)

How can my TControl descendant get notified when its Parent Form in Showing i.e. the Parent Form DoShow method is called?
Is there a message being broadcast to the children (and children or children) when that occurs?
In my specific case, it is a TCustomControl (not TGraphicsControl). so maybe it will be easier?
Thanks.

Delphi 7, How can a child react to the parent form Moving?

I'm writing a TFrame descendant that can host any sort of controls at runtime.
Among its features, under specific conditions, it should show a sort of visual dimmed "mask".
I achieved this effect overlaying a separate TCustomForm descendant class with AlphaBlend,
and for this to work the form must have no parent.
Thus, I need some extra code to keep this window anchored to the Client area of the frame, whether it's been resized or moved.
Not a big deal for resizing: I can override TMyFrame's Resize method.
But what about MOVING?
Let's say the frame is client-aligned to the main form: its Left and Top values don't change if I move the main window, so no WM_MOVE message is sent to the frame.
And I need somethig to be incapsulated INSIDE the TMyFrame unit, in order to keep it reusable.
Is there any other message I can handle in such a situation?
Thank you
Hook the parent form's WindowProc property, or subclass the parent form's window using SetWindowSubclass(), to intercept WM_WINDOWPOSCHANING and WM_WINDOWPOSCHANGED messages.

Is there anyway to stop TWebBrowser from clearing?

Is there anyway to stop TWebBrowser from clearing when I set Self.Parent := nil;?
When it gets to that line (which is necessary for a maximizing function), all the TWebBrowsers in my form clears. Why does it do that and what can I do to avoid this?
EDIT:
'Self' is the current form (in this case AnsForm) being shown on the MainForm.
Previous value of Parent is a Tab in MainForm.
I tried setting Self.Parent to something else but the same thing happens.
Reassigning the TWinControl.Parent property causes that control (in this case, your TForm object) to destroy its HWND (as a child HWND cannot exist without a parent HWND), and a new HWND is not created until the next time that control's Handle property is accessed (if no Parent is available by then, an exception is raised). When a control destroys its HWND, all of its child controls, and their child controls, and so on, destroy their own HWNDs as well. Without an HWND, there is nothing for a control to display, and any content stored in those HWNDs is lost. That is why your TWebBrowser objects get cleared.
Some components cache their current content in memory when their HWND is destroyed and then restore that content when a new HWND becomes available, but TWebBrowser does not (and cannot) do that. Your only option in this situation is to manually reload the current URL again. Otherwise, re-design your UI so the TWebBrowser objects do not reside on a parent control whose Parent property changes.

Moving a MDI Form inside a form

hi
I have a form in which i placed another form as MDI ,on moving the MDI form (Top,Bottom,Left,Right)it goes inside the boundaries of main form so the Mdi gets hidden.
i want to restrict the MDI form to move when it touches the form boundaries.
You need to capture the OnMove event for your child forms, and in that handler you need to make sure your child form's window rect is within the parent's boundary. If not you need to adjust the location of the child form.
An example of how to do this can be found here.

Resources