Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

786 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