Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

шрифт TNode в TTreeView [D5, Win95/98]


orion_st ©   (2002-08-27 11:26:00) 

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


ЮЮ   (2002-08-28 10:26:00) [1]

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


orion_st   (2002-08-28 10:17:00) [2]

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


Skier   (2002-08-27 17:36:00) [3]

>orion_st


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


TTreeView(Node.TreeView).Font


orion_st   (2002-08-27 17:30:00) [4]

> Node.TreeView.Font ?

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

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


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

>orion_st


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



Node.TreeView.Font ?


Skier   (2002-08-27 14:30:00) [6]

>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;



orion_st   (2002-08-27 14:27:00) [7]

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


Song   (2002-08-27 11:28:00) [8]

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


Skier   (2002-08-27 11:28:00) [9]

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


Наверх

Титульная страница Поиск, карта сайта Написать письмо