procedure TVisForm.AdvDrawMenuItem(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; State: TOwnerDrawState);
var
mi: TMenuItem;
r: TRect;
bm: TBitmap;
begin
mi := Sender
as TMenuItem;
with ACanvas
do
begin
Brush.Color := clWindow;
FillRect(ARect);
Brush.Color := clBtnFace;
Windows.CopyRect(r, ARect);
r.Right := 22;
FillRect(r);
if (odSelected
in State)
and (mi.Enabled)
then
begin
Pen.Color :=
RGB(49,105,198);
Brush.Color :=
RGB(198,211,239);
Rectangle(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
end;
if mi.IsLine
then
begin
MoveTo(ARect.Left+25, ARect.Top+(ARect.Bottom-ARect.Top)
div 2);
LineTo(ARect.Right, PenPos.Y);
Exit;
{return;}
end;
{ Adjust rect for the glyph, and move it a bit if selected }
r.Left := ARect.Left+4;
r.Top := ARect.Top+3;
if mi.Enabled
and ((odSelected
in State)
or mi.Checked)
then
InflateRect(r, +1, +1);
{ Draw glyph from associated ImageList/Bitmap }
if ((mi.ImageIndex >= 0)
and (mi.GetImageList <>
nil))
or (
not mi.Bitmap.Empty)
then
begin
if mi.Checked
then
begin
Pen.Color :=
RGB(49,105,198);
Brush.Color :=
RGB(198,211,239);
Rectangle(ARect.Left+1, ARect.Top+1, ARect.Left-1+22, ARect.Bottom-1);
end;
{ Draw glyph stored in Bitmap property... }
if not mi.Bitmap.Empty
then
Draw(r.Left, r.Top, mi.Bitmap)
else
mi.GetImageList.Draw(ACanvas, r.Left, r.Top, mi.ImageIndex, mi.Enabled);
end;
if mi.Checked
and (mi.ImageIndex < 0)
then
begin
bm := TBitmap.Create;
bm.Handle := LoadBitmap(0, PChar(OBM_CHECK));
Pen.Color :=
RGB(49,105,198);
Brush.Color :=
RGB(198,211,239);
Rectangle(ARect.Left+1, ARect.Top+1, ARect.Left-1+22, ARect.Bottom-1);
Draw(ARect.Left+5, ARect.Top+3, bm);
bm.Destroy;
end;
{ Draw menu item text }
Windows.CopyRect(r, ARect);
r.Left := 25;
InflateRect(r, -2, -2);
Brush.Color := clMenu;
SetBkMode(
Handle, TRANSPARENT);
if odSelected
in State
then
SetBkColor(
Handle,
RGB(198,211,239))
else
SetBkColor(
Handle, GetSysColor(COLOR_WINDOW));
if mi.Enabled
then
Font.Color := clMenuText
else
Font.Color := clGrayText;
if odNoAccel
in State
then
DrawText(
Handle, PChar(StripHotkey(mi.Caption)), -1, r,
DT_SINGLELINE
or DT_VCENTER)
else
DrawText(
Handle, PChar(mi.Caption), -1, r, DT_SINGLELINE
or DT_VCENTER);
if mi.ShortCut <> 0
then
begin
r.Left := ARect.Right-TextWidth(ShortcutToText(mi.ShortCut))-5;
DrawText(
Handle, PChar(ShortcutToText(mi.ShortCut)), -1, r,
DT_SINGLELINE
or DT_VCENTER);
end;
end;
end;