To bi trebalo ovako da izgleda:
procedure TForm1.BcCustomDrawModule1DrawMenuItem(Sender: TObject;
AMenuItem: TMenuItem; ACanvas: TCanvas; ARect: TRect;
State: TOwnerDrawState; ABarVisible: Boolean; var DefaultDraw: Boolean);
var
R: TRect;
ImageList: TCustomImageList;
procedure DrawCheckedPattern(Inflate: Boolean);
begin
if odChecked in State then
begin
if Inflate then InflateRect(R, -2, -2);
// ACanvas.Brush.Bitmap := AllocPatternBitmap(clBtnFace, clWhite);
// ACanvas.FillRect(R);
ACanvas.Brush.Color := clBlack;
ACanvas.FrameRect(R);
if Inflate then InflateRect(R, 2, 2);
end;
end;
begin
DefaultDraw := False;
{ menuitem drawing }
if (AMenuItem.Caption = cLineCaption) then
begin
{ background }
DrawGradient(ACanvas, ARect, clWhite, clBtnFace, gsHorizontal);
{ align the text and draw it }
R := ARect;
R.Left := R.Right - ACanvas.TextWidth(AMenuItem.Hint) - 15;
ACanvas.Brush.Style := bsClear;
DrawText(ACanvas.Handle,
PChar(AMenuItem.Hint), Length(AMenuItem.Hint),
R, 0);
{ draw the line so that it won't draw over text }
R := ARect;
Inc(R.Top, (R.Bottom - R.Top) div 2);
R.Bottom := R.Top + 1;
Dec(R.Right, ACanvas.TextWidth(AMenuItem.Hint) + 10 + 10);
ACanvas.Brush.Color := clGray;
ACanvas.FillRect(R);
end else
begin
{ use default drawing for mainmenu top items }
if IsInTopMainMenu(AMenuItem) then
begin
DefaultDraw := True;
Exit;
end;
with ACanvas do
begin
R := ARect;
if odSelected in State then
begin
{ draw frame and selection gradient }
Brush.Color := clGray;
FrameRect(R);
InflateRect(R, -2, -2);
DrawGradient(ACanvas, R, clWhite, AMenuItem.Tag, gsDiagonalLeftRight);
DrawCheckedPattern(False);
{ adjust rect so that text will be aligned to right }
R.Left := R.Right - TextWidth(AMenuItem.Caption) - 5;
Font.Color := clWhite; // caption color
end else
begin
{ draw background gradient }
DrawGradient(ACanvas, R, clWhite, clBtnFace, gsHorizontal);
DrawCheckedPattern(True);
{ leave space for menuitem image }
Inc(R.Left, 38);
Font.Color := clBlack; // caption color
end;
if (odDisabled in State) or (odGrayed in State) then
Font.Color := clGrayText;
{ draw caption }
InflateRect(R, 0, -(
(R.Bottom - R.Top - TextHeight(AMenuItem.Caption) - 1)
div 2));
Brush.Style := bsClear;
DrawText(Handle,
PChar(AMenuItem.Caption), Length(AMenuItem.Caption),
R, 0);
{ draw menuitem image }
with AMenuItem do
begin
ImageList := GetImageList;
if (ImageIndex <> -1) and Assigned(ImageList) then
ImageList.Draw(ACanvas, ARect.Left + 11,
ARect.Top + (ARect.Bottom - ARect.Top - ImageList.Height) div 2, ImageIndex);
end;
end;
end;
end;
Pa sad ti vidi...
donald