Hi All
Well we are now in a pickle.
We have an application with over 70 forms which are distributed as packages,
form size ~80K. At runtime the main executable performs a loadpackage on the
screen bpl and then a findclass of the form's class to instantiate the form.
After a lot of deliberation and justification meetings etc we decided to
upgrade from Delphi 3.02 to D5.01.
During testing we uncovered the MDI/Menu bug discussed earlier.A fix
recommended by a team B player was obtained(attached).
Implementing the fix is proving to be a challenge as the fix in menu.pas
requires a rebuild of VCL50(which we can't do) as we use packages.
I have removed runtime packages from the main executable and its size has
increased fivefold - we can handle this, however when I modified the
packages for each screen to implicitly build required units instead of
requiring vcl50.bpl their size went up to 3MB+ each (from an average of
50-100K) and this is not acceptable.
Is there anyway I can make each screen package use my modified menus.pas but
also use (require) vcl50.bpl?
The supplied fix has aparently been submitted for D6 inclusion, but we do
not know if it has or will be implemented. So the bug may still be present
in D6 for all we know.
MDI/Menu fix for menu.pas as supplied by team B
------------------------------------------------
procedure TMenuItem.RebuildHandle;
const
cFAF = $04; // suggested by Frank Federici, hi Frank!
var
I: Integer;
LRepopulate: Boolean;
begin
if csDestroying in ComponentState then Exit;
if csReading in ComponentState then
FStreamedRebuild := True
else
begin
if FMergedWith <> nil then
FMergedWith.RebuildHandle
else
begin
I := GetMenuItemCount(Handle);
LRepopulate := I = 0;
while I > 0 do
begin
if (WordRec(LongRec(GetMenuState(Handle, I - 1,
MF_BYPOSITION)).Lo).Lo and cFAF) = 0 then
begin
RemoveMenu(Handle, I - 1, MF_BYPOSITION);
LRepopulate := True;
end;
Dec(I);
end;
if LRepopulate then
begin
if (FParent = nil) and (FMenu is TMainMenu) and
(GetMenuItemCount(Handle) = 0) then
begin
DestroyMenu(FHandle);
FHandle := 0;
end
else
PopulateMenu;
MenuChanged(False);
end;
end;
end;
end;
function TMenu.DispatchPopup(AHandle: HMENU): Boolean;
function IsMDIWindowMenu(AItem: TMenuItem): Boolean;
begin
Result := Assigned(Application.MainForm) and
(Application.MainForm.FormStyle = fsMDIForm) and
(Application.MainForm.WindowMenu = AItem);
end;
var
Item: TMenuItem;
LRebuild: Boolean;
begin
Result := False;
Item := FindItem(AHandle, fkHandle);
if Item <> nil then
begin
if not (csDesigning in Item.ComponentState) then Item.InitiateActions;
Item.Click;
LRebuild := Item.InternalRethinkHotkeys(False);
LRebuild := Item.InternalRethinkLines(False) or LRebuild;
if LRebuild then
Item.RebuildHandle;
if IsMDIWindowMenu(Item) then
if SendMessage(Application.MainForm.ClientHandle, WM_MDIREFRESHMENU,
0, 0) <> 0 then
DrawMenuBar(Application.MainForm.Handle);
Result := True;
end
else if not (csDesigning in ComponentState) and (Self is TPopupMenu) then
Items.InitiateActions;
end;
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"