procedure THauptformular.ToolBar1CustomDraw(Sender: TToolBar;
const ARect: TRect;
var DefaultDraw: Boolean);
var
L, P: Integer;
S:
string;
r, ar: TREct;
tp: TPoint;
oc, pc: TColor;
begin
if (DontUseMenuOwnerDraw)
or (Screen.PixelsPerInch >= 120)
then begin
exit;
end;
DefaultDraw := false;
Toolbar1.Canvas.Font.Color := clWhite;
Toolbar1.Canvas.Font.
Name := '
Arial';
Toolbar1.Canvas.Font.Style := [fsBold];
Toolbar1.Canvas.Font.size := 9;
ar := arect;
oc := Toolbar1.Canvas.brush.color;
pc := Toolbar1.Canvas.Pen.Color;
Toolbar1.Canvas.FillRect(arect);
P := 0;
r := Arect;
inc (r.Top, 4);
// Alle Menüs-Einträge normal zeichnen
for L := 0
to MainMenu1.Items.Count - 1
do begin
if MainMenu1.Items[L].Visible
then begin
s := '
' + MainMenu1.Items[L].Caption;
ar.Right := ar.Left + Toolbar1.Canvas.TextWidth(s)+2;
DrawText (Toolbar1.Canvas.Handle, Pchar (s), -1, r, DT_Left + DT_VCenter);
inc (P, Toolbar1.Canvas.TextWidth(s)-1);
r.Left := P;
ar.Left:= p;
end;
end;
ar := arect;
P := 0;
r := Arect;
inc (r.Top, 4);
// Wo ist die Maus?
tp := Toolbar1.ScreenToClient(point (mouse.CursorPos.X, mouse.CursorPos.y));
for L := 0
to MainMenu1.Items.Count - 1
do begin
if MainMenu1.Items[L].Visible
then begin
s := '
' + MainMenu1.Items[L].Caption;
ar.Right := ar.Left + Toolbar1.Canvas.TextWidth(s)+2;
// Ist Maus über einem Menüeintrag?
if MouseInRect(
tp.X,
tp.y, ar.Left-5, r.Top, ar.Right-5, ar.Bottom)
then begin
Toolbar1.Canvas.Pen.Color := clBlack;
Toolbar1.Canvas.brush.Color := DesColMenuSel;
DrawText (Toolbar1.Canvas.Handle, Pchar (s), -1, r, DT_Left + DT_VCenter);
Toolbar1.Canvas.brush.color := oc;
Toolbar1.Canvas.Pen.Color := pc;
break;
end;
inc (P, Toolbar1.Canvas.TextWidth(s)-1);
r.Left := P;
ar.Left:= p;
end;
end;
end;