正在阅读:Delphi实用代码:自绘XP风格菜单Delphi实用代码:自绘XP风格菜单

2004-08-26 10:08 出处:CSDN 作者:nhconch 责任编辑:linjixiong


  else
  if odSelected in State then
  begin
  BrushColor := MainMenuSelectedBackColor;
  PenColor := MainMenuSelectedBorderColor;
  end
  else
  begin
  BrushColor := MainMenuBackColor;
  PenColor := MainMenuBackColor;
  if TMenuItem(Sender).Caption = '帮助(&H)' then ARect.Right := ARect.Right + 1600;
  end;
  ACanvas.Brush.Color := BrushColor;
  ACanvas.Pen.Color := PenColor;
  //ACanvas.FillRect(ARect);
  ACAnvas.Rectangle(ARect);
  ACanvas.Brush.Style := bsClear;
  //绘出文字
  if odGrayed in State then
  ACanvas.Font.Color := clBtnShadow
  else
  ACanvas.Font.Color := clBlack;
  SetRect(TextRect, ARect.left+10, ARect.top+3, ARect.right, ARect.bottom);
  DrawText(ACanvas.Handle, PChar(TMenuItem(Sender).Caption), Length(TMenuItem(Sender).Caption),
  TextRect, DT_LEFT);
  end;

  //绘制子菜单内容
  procedure DrawSubItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState);
  const
  SubMenuBackColor      : TColor = $F7F8F9;
  SubMenuBorderColor    : TColor = $DEEDEF;
  SubMenuSelectedBackColor  : TColor = $EED2C1;
  SubMenuSelectedBorderColor: TColor = $C08000;
  SubMenuLineColor      : TColor = $C8D0D4;
  //SubMenuHotLightBorderColor: TColor = $C08000;
  SubMenuGrayedBackColor  : TColor = $F7F8F9;//$DEEDEF;
  var
  BrushColor, PenColor: TColor;
  TextRect: TRECT;
  str: String;
  ImageList: TCustomImageList;
  begin
  if (odGrayed in State) and not(TMenuItem(Sender).IsLine) then
  begin
  BrushColor := SubMenuGrayedBackColor;
  {if odSelected in State then
  PenColor := SubMenuSelectedBorderColor
  else}

 


察看评论详细内容 我要发表评论
作者笔名 简短内容 发表时间
:

键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品