首页 > 代码库 > 自定义popupmenu菜单背景色

自定义popupmenu菜单背景色

procedure TForm1.N11DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;

  Selected: Boolean);

begin

 If (Selected) Then

 begin

 

 

 ACanvas.Font.Color := clWhite  ;

  ACanvas.Brush.Color := clWebDodgerBlue;

      ACanvas.FillRect(ARect);

         DrawText(ACanvas.Handle, PChar(‘   取消开机启动‘), -1, ARect, DT_LEFT Or DT_LEFT Or DT_SINGLELINE Or DT_NOCLIP);

 end

  Else

  begin

  ACanvas.Font.Color := clblack;

 

    ACanvas.Brush.Color := clWebSnow;

    ACanvas.FillRect(ARect);

 

    DrawText(ACanvas.Handle, PChar(‘   取消开机启动‘), -1, ARect, DT_LEFT Or DT_LEFT  Or DT_SINGLELINE Or DT_NOCLIP);

  end;

end;