Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.07.21;
Скачать: CL | DM;

Вниз

Отрисовка RoundRect   Найти похожие ветки 

 
Семен Сорокин ©   (2003-07-08 14:01) [0]

Добрый день всем, есть следующий код по отрисовке на канве TListView в одной из колонок:
procedure TfmSelGraph.lvParGraphsCustomDrawSubItem(Sender: TCustomListView;
Item: TListItem; SubItem: Integer; State: TCustomDrawState;
var DefaultDraw: Boolean);
var
_rect: TRect;
_i : integer;
_h : integer;
_w : integer;
begin
if Assigned(Item.Data) and (SubItem = 4) then begin
DefaultDraw := false;
_rect := Item.DisplayRect(drBounds);
for _i := 0 to lvParGraphs.Columns.Count - 2 do
_rect.Left := _rect.Left + lvParGraphs.Columns[_i].Width;
with lvParGraphs.Canvas do begin
Brush.Color := lvParGraphs.Color;
Brush.Style := bsSolid;
FillRect(_rect);
Pen.Style := psDot;
Pen.Color := clBlack;
_h := _rect.Bottom - _rect.Top;
_w := _rect.Right - _rect.Left;
MoveTo(_rect.Left + 2, _rect.Top + _h div 2);
LineTo(_rect.Right - 2, _rect.Top + _h div 2);
Pen.Style := psSolid;
Brush.Color := $637BED; //!!!! Вот этим цветом не заливается
RoundRect(_rect.Left + _w div 2 - _h div 2, _rect.Top + 1,
_rect.Left + _w div 2 + _h div 2, _rect.Bottom - 1,
_h div 3, _h div 3)
end
end
end;

Все нормально рисуется, за исключением того, что ф-я RoundRect канвы не заливает цветом Brush.Color.
В чем может быть проблема?

Пробовал различные варианты, например без предварительной заливки ( FillRect(_rect);), сразу задав цвет Brush.Color, тогда рисует как надо, т.е. берет цвет первый раз назначенный кисти.

справка по RoundRect:
Use RoundRect to draw a rounded rectangle using Pen and fill it with Brush....

С уважением, Семен


 
Семен Сорокин ©   (2003-07-08 14:43) [1]

И все-же, может кто сталкивался?


 
Семен Сорокин ©   (2003-07-08 16:55) [2]

Up


 
Poirot ©   (2003-07-08 17:18) [3]

Down!
Попробуй устанавливать цвета и стиль непосредственно перед прорисовкой!!! Возможно кто-то меняет стиль!!! Может порядок попробуй поменять - что-то за глюк такой был у меня когда-то!


 
Семен Сорокин ©   (2003-07-09 09:52) [4]

смог исправить только копированием на битмап:

procedure TfmSelGraph.lvParGraphsCustomDrawSubItem(Sender: TCustomListView;
Item: TListItem; SubItem: Integer; State: TCustomDrawState;
var DefaultDraw: Boolean);
var
_bmp : TBitmap;
_rect: TRect;
_i : integer;
_h : integer;
_w : integer;
begin
if Assigned(Item.Data) and (SubItem = 4) then begin
DefaultDraw := false;
_rect := Item.DisplayRect(drBounds);
for _i := 0 to lvParGraphs.Columns.Count - 2 do
_rect.Left := _rect.Left + lvParGraphs.Columns[_i].Width;
_bmp := TBitmap.Create;
with lvParGraphs.Canvas do
try
Brush.Color := lvParGraphs.Color;
FillRect(_rect);
_h := _rect.Bottom - _rect.Top;
_w := _rect.Right - _rect.Left;
_bmp.Width := _w;
_bmp.Height := _h;
_bmp.Transparent := true;
_bmp.Canvas.Pen.Style := psDot;
_bmp.Canvas.Pen.Color := clBlack;
_bmp.Canvas.MoveTo(2, _h div 2);
_bmp.Canvas.LineTo(_w - 2, _h div 2);
_bmp.Canvas.Pen.Style := psSolid;
_bmp.Canvas.Brush.Color := clRed; //PParameter(Item.Data)^.Color;
_bmp.Canvas.Brush.Style := bsSolid;
_bmp.Canvas.RoundRect(_w div 2 - _h div 2, 1, _w div 2 + _h div 2, _h - 1, _h div 3, _h div 3);
CopyRect(_rect, _bmp.Canvas, _bmp.Canvas.ClipRect);
finally
_bmp.Free
end
end
end;



Страницы: 1 вся ветка

Текущий архив: 2003.07.21;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.017 c
3-67666
RH
2003-06-26 12:08
2003.07.21
Нужно заполнить поле


3-67709
victor_ch
2003-06-27 10:21
2003.07.21
Как узнать тип полей программно


14-68002
Фигаро2000
2003-07-03 15:26
2003.07.21
ModelMaker 6.01 -> 6.20


1-67892
Fantasy
2003-07-07 14:23
2003.07.21
ошибка в EHLib


6-67956
Den_IS01
2003-05-14 13:26
2003.07.21
Принудительно перейти по ссылке в TWebBrouser