Solved

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

Posted on 2000-04-21
5
479 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

914 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

18 Experts available now in Live!

Get 1:1 Help Now