Below is the fix posted by a teamB member that updates the problematic code
in Menus.pas.
When we build our application it tries to recompile the tchart component,
perhaps it has the menu.pas in its uses clause ?
To replicate the problem use the simple MDI Application (File - New -
Projects - MDI Application) in Delphi 5.
Create the project, and add a TMainMenu component with a single MenuItem to
the child form.
When the application is run on Win98 and two MDI children are created and
maximised and the Ctrl-TAB key is used to swap between the 2 forms the menus
get completely messed up and the form icon prceding the menu disappears.
BTW, this problem does not occur on NT or WIN2000
Neil
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"