直接拖个RzMenuController1放到窗体上,放上菜单,设置OwnerDraw:=True
效果图: 600) this.width = 600;">
每个Item中关联
procedure TForm1.N1DrawItem(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; Selected: Boolean);
begin
DrawMenuItem(Sender as TMenuItem,ACanvas,ARect,Selected);
end;
procedure TForm1.DrawMenuItem(Item: TMenuItem; ACanvas: TCanvas;
ARect: TRect; Selected: Boolean);
var
hMenu : HWND;
TmpCanvas : TCanvas;
TmpRect:TRect;
begin
hMenu := WindowFromDC(ACanvas.Handle);
if ( hMenu <> Handle ) and ( hMenu <> 0 ) then
begin
TmpCanvas := TCanvas.Create;
try
TmpCanvas.Handle := GetDC(0);
TmpCanvas.Pen.Color := $AE7323;//CF9365;
TmpCanvas.Brush.Color:= $AE7323;//CF9365;
GetWindowRect(hMenu, TmpRect);
TmpCanvas.FrameRect(TmpRect);
InflateRect(TmpRect, -1, -1);
TmpCanvas.Brush.Color := $FFFFFF;//DFDBDF;
TmpCanvas.FrameRect(TmpRect);
InflateRect(TmpRect, -1, -1);
TmpCanvas.FrameRect(TmpRect);
finally
ReleaseDC(0, TmpCanvas.Handle);
if Assigned(TmpCanvas) then FreeAndNil(TmpCanvas);
end;
end;
end;