I want to change the menu backgroup and highlighted color in Delphi,how can
I do that?
thanks.
type
TMyMenuItem = class(TMenuItem);
procedure TForm1.MenuItemAdvancedDrawItem(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; State: TOwnerDrawState);
var
TopLevel: Boolean;
Win98Plus: Boolean;
OldAdvancedDrawItem: TAdvancedMenuDrawItemEvent;
begin
with ACanvas do
begin
Win98Plus := (Win32MajorVersion > 4) or
((Win32MajorVersion = 4) and (Win32MinorVersion > 0));
TopLevel := TMenuItem(Sender).GetParentComponent is TMainMenu;
if (odSelected in State) and (not TopLevel or (TopLevel and not
Win98Plus)) then
begin
Brush.Color := clRed;
Font.Color := clWhite;
end
else if Win98Plus and (odInactive in State) then
begin
Brush.Color := clGreen;
Font.Color := clSilver;
end
else
begin
Brush.Color := clGreen;
Font.Color := clWhite;
end;
OldAdvancedDrawItem := TMenuItem(Sender).OnAdvancedDrawItem;
try
TMenuItem(Sender).OnAdvancedDrawItem := nil;
TMyMenuItem(Sender).AdvancedDrawItem(ACanvas, ARect, State, TopLevel);
finally
TMenuItem(Sender).OnAdvancedDrawItem := OldAdvancedDrawItem;
end;
end;
end;
"richard tsang" <zc...@21cn.com> schreef in bericht news:3b398735_2@dnews...