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

Вниз

шрифт TNode в TTreeView   Найти похожие ветки 

 
orion_st ©   (2002-08-27 11:26) [0]

Как можно выделить TNode в TTreeView другим шрифтом(цветом)?
Если можно, ответьте и на email.


 
Song ©   (2002-08-27 11:28) [1]

Написать обработчик для TTreeView.onAdvancedCustomDraw/onAdvancedCustomDrawItem


 
Skier ©   (2002-08-27 11:28) [2]

>orion_st
см. событие TTreeView.OnCustomDrawItem
Пример есть в Help-е.


 
orion_st ©   (2002-08-27 14:27) [3]

В хелпе на это событие примера нет. Там есть Node, а как из него выцепить его шрифт?


 
Skier ©   (2002-08-27 14:30) [4]

>orion_st


> В хелпе на это событие примера нет


"Папы этого ответ помещаю в книжке..."
Специально для ВАС !


procedure TCustomDrawForm.TVCustomDrawItem(Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
var
NodeRect: TRect;
begin
with TV.Canvas do
begin
//If DefaultDraw it is true, any of the node"s font properties can be
//changed. Note also that when DefaultDraw = True, Windows draws the
//buttons and ignores our font background colors, using instead the
//TreeView"s Color property.

if cdsSelected in State then
begin
Font.Assign(SelectedFontDialog.Font);
Brush.Color := SelBkgColorDialog.Color;
end;
DefaultDraw := FDefaultDrawItem;
//DefaultDraw = False means you have to handle all the item drawing yourself,
//including the buttons, lines, images, and text.

if not DefaultDraw then

begin
//draw the selection rect.
if cdsSelected in State then
begin
NodeRect := Node.DisplayRect(True);
FillRect(NodeRect);
end;

NodeRect := Node.DisplayRect(False);

if None1.Checked then

//no bitmap, so paint in the background color.
begin
Brush.Color := BkgColorDialog.Color;
Brush.Style := FBrushStyle;
FillRect(NodeRect)
end
else
//don"t paint over the background bitmap.

Brush.Style := bsClear;

NodeRect.Left := NodeRect.Left + (Node.Level * TV.Indent);

//NodeRect.Left now represents the left-most portion of the expand button

DrawButton(NodeRect, Node);

NodeRect.Left := NodeRect.Left + TV.Indent + FButtonSize;

//NodeRect.Left is now the leftmost portion of the image.

DrawImage(NodeRect, Node.ImageIndex);

NodeRect.Left := NodeRect.Left + ImageList.Width;

//Now we are finally in a position to draw the text.

TextOut(NodeRect.Left, NodeRect.Top, Node.Text);

end;
end;
end;




 
Skier ©   (2002-08-27 14:34) [5]

>orion_st


> Там есть Node, а как из него выцепить его шрифт?



Node.TreeView.Font ?


 
orion_st ©   (2002-08-27 17:30) [6]

> Node.TreeView.Font ?

Такого св-ва нет. Ты по каким Дельфям смотришь? У меня 5-е.
Тот кусок кода есно заработал. :)

Уточню, проблему. Нужно чтобы при формировании дерева сразу
выделялись те Node, которые соответсвуют определенному условию.


 
Skier ©   (2002-08-27 17:36) [7]

>orion_st


> Такого св-ва нет.


TTreeView(Node.TreeView).Font


 
orion_st ©   (2002-08-28 10:17) [8]

Извини, что я попался такой непонятливый, но
TTreeView(Node.TreeView).Font мне выделяет весь TreeView, а надо только отдельные Node в ветви.


 
ЮЮ ©   (2002-08-28 10:26) [9]

> Там есть Node, а как из него выцепить его шрифт?
У Node, естесственно, нет никакого Font,
но в TTreeView.OnCustomDrawItem ты и определяешь каким цветом тебе рисовать конктретный Node и им рисуешь



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

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

Наверх




Память: 0.49 MB
Время: 0.014 c
1-27089
c0pyc@t
2002-08-28 09:36
2002.09.09
Уникальный ID


4-27282
Zmey
2002-07-19 17:22
2002.09.09
RichEdit


1-26992
CrazyAngel
2002-08-27 14:55
2002.09.09
Sleep но не sleep


4-27258
Anton_
2002-06-28 10:07
2002.09.09
handle


3-26893
Sergey L.
2002-08-20 09:48
2002.09.09
Работа с отчетами.