Solved

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

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

12 Experts available now in Live!

Get 1:1 Help Now