Solved

minimize MDIChild form

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to fill array with TArray.Create? 14 90
select query - oracle 16 100
creating threads in delphi 1 104
Firemonkey BASS_Init into a thread 17 7
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 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