Текущий архив: 2003.11.24;
Скачать: CL | DM;
Вниз
Как изменить font в PopupMenu? Найти похожие ветки
← →
Grokhem © (2003-11-13 17:20) [0]Привет всем!
Как изменить font в PopupMenu?
← →
Maxud © (2003-11-13 17:42) [1]В PopupMenu: TPopupMenu св-во OwnerDraw := true.
В N1: TMenuItem обрабатываешь OnAdvancedDrawItem:
ACanvas.Font.Name := "Times New Roman";
ACanvas.Font.Style := [fsbold];
ACanvas.TextOut(1,1,"wau");
← →
Grokhem © (2003-11-13 17:48) [2]Огромное спасибо
Про этот способ не подумал :))
← →
Grokhem © (2003-11-14 17:53) [3]Вот только для Д4 пришлось
обрабатывать
не OnAdvancedDrawItem - которого там нет
а OnDrawItem и
OnMeasureItem чтобы у меню была ширина нормальная
Вот что у меня вышло
может кому пригодится
...
CurFont := TFont.Create();
CurFont.Name :="Courier New";
CurFont.Size := 12;
...
CurFont.Free;
...
procedure TForm1.miRajDrawItem(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; Selected: Boolean );
begin
ACanvas.Font := CurFont;
if selected then
begin
ACanvas.Pen.Color := clBlack;
ACanvas.Brush.Color := 13349545;
ACanvas.FillRect(rect(ARect.Left,ARect.top,12,ARect.Bottom ));
ACanvas.Textout(12,ARect.top,AddCharR(" ",(Sender as TMenuItem).Caption,MaxWidth));
ACanvas.Brush.Color := clBlack;
ACanvas.FrameRect(rect(ARect.Left,ARect.top,ARect.Right,ARect.Bottom ));
end else
begin
ACanvas.Brush.Color := clBtnFace;
ACanvas.FillRect(rect(ARect.Left,ARect.top,12,ARect.Bottom ));
ACanvas.Brush.Color := clWhite;
ACanvas.Textout(12,ARect.top,AddCharR(" ",(Sender as TMenuItem).Caption,MaxWidth));
end
end;
procedure TForm1.miRajMeasureItem(Sender: TObject; ACanvas: TCanvas;
var Width, Height: Integer);
begin
ACanvas.Font := CurFont;
Width :=ACanvas.TextWidth((Sender as TMenuItem).Caption);
Height :=ACanvas.TextHeight((Sender as TMenuItem).Caption);
end;
Страницы: 1 вся ветка
Текущий архив: 2003.11.24;
Скачать: CL | DM;
Память: 0.47 MB
Время: 0.019 c