Solved

MDI Bug-Fix in Delphi 5 this is not a Question ;-)

Posted on 2000-04-21
5
497 Views
Last Modified: 2010-04-04
Fixing the Borland Delphi MDI problems.
Since Inprise hasn't very interests of fixing her bug, I post it here!

greating
Thomas

------------------------------------------------------------------------------------------------------------------

The following MergeMenu function fixes two bugs
=======================================

When do the Bugs appear:

- more than one MDI-Child is maximized and
- switching to another window and
- the child has a menu and
- the menu on the MainMenu's property "automerge=true"

The Bugs are:

1.) The close button grayed out.
2.) In Delphi 5 the system-icons and Menu where drawn correctly, but the mdi-child-system-icons are missing. So the menu moves left and under win98/2000 this looks very funny.
------------------------------------------------------------------------------------------------------------------

How to fix:
========

1.) Sorry You can only do it, if you have the professional or enterprise version.

2.) Add the source path in the environment options:
Menu => Tools/Environment options
Tab => Library
Library path => $(DELPHI)\Source\VCL

3.) Edit Forms.pas

4.) Compile the your MDI-Application

------------------------------------------------------------------------------------------------------------------
Full Source of the function:
======================

procedure TCustomForm.MergeMenu(MergeState: Boolean);
var
AMergeMenu: TMainMenu;
//Add these variables here
Size,
Style : longint;
begin
if not (fsModal in FFormState) and
(Application.MainForm <> nil) and
(Application.MainForm.Menu <> nil) and
(Application.MainForm <> Self) and
((FormStyle = fsMDIChild) or (Application.MainForm.FormStyle <> fsMDIForm)) then
begin
AMergeMenu := nil;
if not (csDesigning in ComponentState) and (Menu <> nil) and
(Menu.AutoMerge or (FormStyle = fsMDIChild)) then AMergeMenu := Menu;
with Application.MainForm.Menu do
if MergeState then Merge(AMergeMenu) else Unmerge(AMergeMenu);
// =====================> Add in Delphi 5 <==================
if MergeState and (FormStyle = fsMDIChild) and (WindowState = wsMaximized) then
begin
{ Force MDI to put back the system menu of a maximized child }
Size := ClientWidth + (Longint(ClientHeight) shl 16);
SendMessage(Handle, WM_SIZE, SIZE_RESTORED, Size);
// ==================> Remove from Delphi 2?,3?,4 <================
// SendMessage(Handle, WM_SIZE, SIZE_MAXIMIZED, Size);
// ====================> Add in Delphi 2?,3?,4,5 <=================
//new lines to patch the grayed out close-button
Style:=GetWindowLong(Handle,GWL_STYLE) or ws_sysmenu;
SetWindowLong(Handle, GWL_STYLE, Style);
end;
// ==========================================================
end;
end;
 
0
Comment
Question by:huehnsoftware
[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
 

Accepted Solution

by:
huehnsoftware earned 50 total points
ID: 2738622
cool *g*
0
 
LVL 10

Expert Comment

by:ptmcomp
ID: 2741464
Perhaps this replaces my ugly workaround...
0
 
LVL 3

Expert Comment

by:darinw
ID: 3084704
This question has been undeleted.  The points for this question were originally 50 but have been reduced to 0
0
 
LVL 3

Expert Comment

by:darinw
ID: 3084730
Hi everyone. I just happened to stumble across this one while looking through a search on a mostly unrelated matter.

huehnsoftware - you have to accept an answer to a question or it will be deleted by the system after 21ish days.

darinw
Customer Service
0
 
LVL 3

Expert Comment

by:darinw
ID: 3084732
Comment accepted as answer
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

623 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