Solved

minimize MDIChild form

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

Independent Software Vendors: 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 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