Solved

minimize MDIChild form

Posted on 1997-03-23
5
1,302 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
  • 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now