procedure TForm1.PopUpDrawItems(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; Selected: Boolean);
var
r: TRect;
FontName: TFontName;
ico: TIcon;
begin
if TMenuItem(Sender).Tag < 0 then
begin
ACanvas.Brush.Color := clInactiveCaption;
ACanvas.Pen.Color := clCaptionText;
ACanvas.Font.Color := ACanvas.Pen.Color;
FontName := ACanvas.Font.Name;
ACanvas.Font.Name := 'arial';
case TMenuItem(Sender).Tag of
-1: begin
Inflaterect(ARect, -1, -1);
DrawGradient(ACanvas, ARect, TRUE, [clGradientActiveCaption,
clGradientInactiveCaption]);
// oder: DrawGradient(ACanvas, ARect, TRUE, [$00964220, $00BD8045]);
DrawMYCaption(ACanvas, ARect, TMenuItem(Sender).Caption,
DT_SINGLELINE or DT_VCENTER or DT_CENTER, TRUE, TRUE);
end;
-2: begin
DrawGradient(ACanvas, ARect, FALSE, [clGradientActiveCaption,
clGradientInactiveCaption, clGradientActiveCaption]);
//oder: DrawGradient(ACanvas, ARect, FALSE, [$00964220, $00BD8045, $00964220]);
ico := TIcon.Create;
ico.Handle := LoadIcon(HInstance, MAKEINTRESOURCE(2) );
ACanvas.Draw(4, 1, ico);
FreeAndNil(ico);
// oder: ACanvas.Draw(1, 1, Application.Icon);
ACanvas.Font.Style := ACanvas.Font.Style + [fsBold];
ACanvas.Font.Size := ACanvas.Font.Size + 6;
DrawMYCaption(ACanvas, ARect, TMenuItem(Sender).Caption,
DT_SINGLELINE or DT_VCENTER or DT_CENTER, TRUE, TRUE);
ACanvas.Font.Size := ACanvas.Font.Size - 6;
ACanvas.Font.Style := ACanvas.Font.Style - [fsBold];
end;
end;
ACanvas.Font.Name := FontName;
end else
begin
if TMenuItem(Sender).IsLine then
begin
Inflaterect(ARect, -2, -3);
DrawGradient(ACanvas, ARect, TRUE, [clBtnFace, clBtnHighlight]);
end else
begin
ACanvas.FillRect(ARect);
FontName := ACanvas.Font.Name;
ACanvas.Font.Name := mnuExtraFont;
ACanvas.Font.Color := clNavy;
//ACanvas.Font.Style := [fsBold];
ACanvas.Font.Size := ACanvas.Font.Size + 4;
r := ARect;
r.Right := mnuCheckBoxWidth;
if TMenuItem(Sender).Hint = 'Checker' then
if TMenuItem(Sender).Checked
then DrawMYCaption(ACanvas, r, 'R', DT_SINGLELINE or DT_VCENTER or DT_CENTER, FALSE)
else DrawMYCaption(ACanvas, r, '£', DT_SINGLELINE or DT_VCENTER or DT_CENTER, FALSE);
//ACanvas.Font.Style := [];
ACanvas.Font.Size := ACanvas.Font.Size - 4;
ACanvas.Font.Name := FontName;
if TMenuItem(Sender).Enabled then
begin
if not Selected
then ACanvas.Font.Color := clMenuText
else ACanvas.Font.Color := clHighlightText;
end else
ACanvas.Font.Color := clGrayText;
ARect.Left := mnuCheckBoxWidth;
DrawMYCaption(ACanvas, ARect, TMenuItem(Sender).Caption,
DT_SINGLELINE or DT_VCENTER or DT_LEFT, FALSE);
end;
end;
end;
procedure TForm1.mnuOnMeasureItem(Sender: TObject;
ACanvas: TCanvas; var Width, Height: Integer);
begin
Width := Width + mnuCheckBoxWidth;
if TMenuItem(Sender).Tag = -2 then Height := Application.Icon.Height + 2;
end;