Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.022 c
14-79104
Yttrium
2003-11-03 01:01
2003.11.24
Lazarus, косяк при компоновке под Linux


3-78764
pashaz
2003-11-02 20:33
2003.11.24
вывод в DBGrid


3-78761
Aleksandr
2003-11-03 11:59
2003.11.24
Как бороться с открытой сессией Парадокса?


14-79136
Alibaba
2003-10-31 22:28
2003.11.24
Иконки


3-78785
GIL
2003-11-05 14:37
2003.11.24
QuickReport




   Наверх