Solved

minimize MDIChild form

Posted on 1997-03-23
5
1,318 Views
Last Modified: 2008-03-10
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
Comment
Question by:forger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 

Expert Comment

by:andrewk032397
ID: 1334924
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
 
LVL 3

Accepted Solution

by:
sperling earned 100 total points
ID: 1334925
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
 
LVL 3

Expert Comment

by:sperling
ID: 1334926
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
 

Author Comment

by:forger
ID: 1334927
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
 
LVL 3

Expert Comment

by:sperling
ID: 1334928
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question