首页  编辑  

自定义菜单外观

Tags: /超级猛料/VCL/Menu.菜单/   Date Created:
首先将菜单的ownerdraw属性设置为true;然后在菜单项的drawitem中写入代码即可。
procedure TForm1.New1DrawItem(Sender: TObject; ACanvas: TCanvas;
 ARect: TRect; Selected: Boolean);
begin
 acanvas.Font.Color:=clred;
 if selected then
   SetBkColor(acanvas.handle,clgreen)
 else
   setBkcolor(acanvas.handle,clblue);
 acanvas.TextRect(arect,0,0,new1.caption);
end;