Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1340
  • Last Modified:

minimize MDIChild form

I face a problem in minimizing MDI child forms.
All minizied forms are the same size, and only small part of the caption
is viewed. It is exactly like you minimize forms or sources at design
time in Delphi.
Another problem is that the Hint property doesn't work on the caption of
the form so, pointing the mouse at the minimized form doesn't activate
the Hint.
 If you have any suggestion regarding these two problems please email me directlly.
 Thanks,
        Uri.
0
forger
Asked:
forger
  • 3
1 Solution
 
andrewk032397Commented:
have you tried:

MDIChildName.WindowState := wsMinimized;

I had the same problem and found that the above gave me an EAccessViolation - i have no idea why. What I did was use the "FindComponent" method of the OWNER of the MDIChild to locate the MDIChild using it's "Name" property and then use the resultant TComponent to access the MDIChild to minimize the window. My final code looked like this:

(Form1.Components[Form1.FindComponent('MDIChildName')] as TForm).WindowState := wsMinimized;

Now the above worked for me, but it may not for you. The least you can do is give it a bash.

Please tell me if there is a better way (I'm sure there is).

Hope it helps, Andrew
0
 
sperlingCommented:
The "bubble" hint is a tough one, as long as delphi don't support it. Tricking the app into displaying the long hint for a minimized window is not too complicated, though.

Add a procedure to the child form:
procedure WMNCHitTest(var message : TMessage); message WM_NCHITTEST;

Implement as follows:

procedure TMDIChild.WMNCHitTest(var message : TMessage);
begin
  inherited;
  if (message.Result = HTCAPTION) and (WindowState=wsMinimized) then begin
    // Here, call a public routine in your main form to display the long hint for the window.
  end;
end;

If you need bubble hints, you'll have to implement this functionality from scratch... Trapping WM_NCHITTEST messages, setting timers, capturing and releasing the mouse, displaying and hiding the bubble and so on.


The size of minimized MDI childs you cannot do anything about.
What you could do, is to trap the minimize message, and instead of minimizing, resize the form to whatever size you want. But, then you'll also have to modify the system menu (Alt+Space menu) of the MDI childs, trap all clicks on the minimize/maximize buttons and so on, as the form will still, according to windows, not be minimized. This can ofcourse be done, but it'll be a heck of a lot of work.


Sorry if this was no help, but what you're asking ain't exactly "plain Delphi"... It can be done, but as said before, it'll be a *lot* of work... If you decide to implement it anyway, I think I've given you a few pointers to get started.


Regards,

Erik.
0
 
sperlingCommented:
Regarding your comments...

Do you have an event handler assigned to the Application.OnHint event? If so, make it public and use that. If not create a statusbar for long hints, and create an Application.OnHint event which displays the passed string in the statusbar. The standard MDIApp project template coming with Delphi is a good example...

You cannot have MDI childs show in the taskbar. You can, however, create a new blank form when a MDI child is minimized (or created), and give them the same caption. Using miscellaneous event handlers, you could make this work as if the MDI child was actually showing in the taskbar. When a user clicks on your dummy form in the taskbar, just restore and switch focus to the associated MDI child.

Regards,

Erik.
0
 
forgerAuthor Commented:
You have been great help Erik. I tried it and it works fine, my only problem is that I have to add code into all my forms. Do you have an idea how can I create a component that would catch the WMNCHitTest message which arrives to the form on which the component was placed on?
0
 
sperlingCommented:
I don't think you can. Unless you start using hooks (lookup SetWindowsHookEx in help), which you really shouldn't do to save som coding. Hooks affect the total performance of windows. The WM_NCHITTEST message doesn't arrive to your forms components when the form recognizes it.

You could create a new blank form, add the functionality and then change all your forms to inherit from this form instead of the standard TForm. If you're using D2, have a look at the Object Repository.

Regards,

Erik.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now