TTreeView.OnCustomDrawItem
TTreeNode *node;
node = this->TreeView1->Items->Add(, "AAAA");
TreeView1->Items->AddChild(node, "aaa1");
TreeView1->Items->AddChild(node, "aaa2");
TreeView1->Items->AddChild(node, "aaa3"); node = this->TreeView1->Items->Add(, "BBBB");
TreeView1->Items->AddChild(node, "aaa1");
TreeView1->Items->AddChild(node, "aaa2");
TreeView1->Items->AddChild(node, "aaa3");
循环插入节点
TTreeNode *anode;
for (int i = ; i < ; i++)
{
anode = this->TreeView1->Items->Add(, "Node" + String(i));
TreeView1->Items->AddChild(anode, "aaa1");
TreeView1->Items->AddChild(anode, "aaa2");
TreeView1->Items->AddChild(anode, "aaa3");
}
c++
/*
The following example shows how the OnCustomDrawItem event
handler draws items and lines of the tree view after the
OnCustomDraw event handler has filled in the background.
*/
void __fastcall TCustomDrawForm::TVCustomDrawItem(TCustomTreeView *Sender,
TTreeNode *Node, TCustomDrawState State, bool &DefaultDraw)
{
TRect NodeRect;
/*
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 (State.Contains(cdsSelected))
{
TV->Canvas->Font->Assign(SelectedFontDialog->Font);
TV->Canvas->Brush->Color = SelBkgColorDialog->Color;
}; DefaultDraw = FDefaultDrawItem;
/*
DefaultDraw = False means you have to handle all the
item drawing yourself, including the buttons, lines,
images, and text.
*/
if (!DefaultDraw)
{
//draw the selection rect.
if (State.Contains(cdsSelected))
{
NodeRect = Node->DisplayRect(True);
TV->Canvas->FillRect(NodeRect);
};
NodeRect = Node->DisplayRect(False); if (None1->Checked)
//no bitmap, so paint in the background color.
{
TV->Canvas->Brush->Color = BkgColorDialog->Color;
TV->Canvas->Brush->Style = FBrushStyle;
TV->Canvas->FillRect(NodeRect);
}
else
//don't paint over the background bitmap.
TV->Canvas->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); // See the CustomDraw demo NodeRect.Left = NodeRect.Left + TV->Indent + FButtonSize;
//NodeRect->Left is now the leftmost portion of the image.
DrawImage(&NodeRect, Node->ImageIndex); // See the CustomDraw demo NodeRect.Left = NodeRect.Left + ImageList->Width;
//Now we are finally in a position to draw the text. TV->Canvas->TextOut(NodeRect.Left, NodeRect.Top, Node->Text);
};
} delphi
{
The following example shows how the OnCustomDrawItem event
handler draws items and lines of the tree view after the
OnCustomDraw event handler has filled in the background.
}
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 := False; // 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); // See the CustomDraw demo NodeRect.Left := NodeRect.Left + TV.Indent + FButtonSize;
//NodeRect.Left is now the leftmost portion of the image.
DrawImage(NodeRect, Node.ImageIndex); // See the CustomDraw demo 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;
TTreeView.OnCustomDrawItem的更多相关文章
- 给 TTreeView 添加复选框
//1.引用单元 uses Commctrl ; //2.定义私有过程 procedure tvToggleCheckbox(TreeView: TTreeView;Node: TTreeNode;i ...
- delphi TTreeView组件遍历磁盘目录
TTreeView组件遍历磁盘目录 实例说明 TTreeView组件是一个以分枝结构或者说树状结构显示数据的组件,以该组件显示数据具有较好的等级关系和逻辑层次,并且易于操作.在组件中显示的数据结构与系 ...
- 学习 TTreeView [1] - TTreeNodes、TTreeNode 与 Items、Items.Count、Items.Clear
填写 TTreeView 的内容一般是这样开始的(下图), 不过我觉得最好习惯用动态建立. 打个比方: 譬如 TreeView 是一个军营的"营部"! 这里会有营长.连长.排长.班 ...
- 学习 TTreeView [3] - Add、AddChild、AddFirst、AddChildFirst、Parent
本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Contro ...
- TTreeView TTreeNodes TTreeNode
TTreeView 填写 TTreeView 的内容一般是这样开始的(下图), 不过我觉得最好习惯用动态建立. 打个比方: 譬如 TreeView 是一个军营的"营部"! 这里会有 ...
- delphi -----TTreeView
TTreeView 与两个重要的类相关:TTreeNodes.TTreeNode . TTreeNodes即是TTreeView 的Items属性,TTreeNodes是TTreeNode的合集,TT ...
- delphi中TTreeView的使用方法
[学习万一老师博客摘要] TTreeView 与两个重要的类相关:TTreeNodes.TTreeNode . TTreeNodes即是TTreeView 的Items属性,TTreeNodes是TT ...
- 学习 TTreeView [2] - Items.Item[i]、Items[i]、.Text、SetFocus(设置焦点)、Select(选择)
本例效果图: 源码: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Co ...
- 学习 TTreeView [16] - 给 TTreeView 添加复选框 (回复 "丁永其" 的问题)
问题来源: http://www.cnblogs.com/del/archive/2008/05/15/1114450.html#1199402 本例效果图: unit Unit1; interfac ...
随机推荐
- 投行的码工 Dead-end job
发信人: icestonesy (无忧), 信区: Quant 标 题: 投行的码工怎么样? 发信站: BBS 未名空间站 (Sat May 16 23:25:00 2015, 美东) 最近看到不少 ...
- Hadoop之 Balancer平衡速度
1. dfs.datanode.max.transfer.threads 修改dfs.datanode.max.transfer.threads=4096 (如果运行HBase的话建议为16384), ...
- ORA-32004 的错误处理
启动数据库时,收到了ORA-32004 的错误,错误多是一些过时且在当前版本中不在使用的参数,如果碰到类似的错误,只需要将其 reset即可. SQL> startup;ORA-32004: o ...
- nginx 知识点
全部指令目录(淘宝翻译):http://tengine.taobao.org/nginx_docs/cn/docs/dirindex.html nginx 命令语法: nginx -s [signal ...
- C# List的深复制(转)
C# List的深复制 1.关于深拷贝和浅拷贝 C#支持两种类型:值类型和引用类型 值类型(Value Type):如 char, int, float,枚举类型和结构类型 引用类型(Referenc ...
- 理解REST和SOA
REST -- REpresentational State Transfer 直接翻译:表现层状态转移. 精辟理解:URL定位资源,用HTTP动词(GET,POST,DELETE,DETC)描述操作 ...
- VS2010中visual assist x的一些问题
1.如你想输入return关键字,那么在你输入r的时候该工具就会把带r的相关函数都列出,你选择一个即可,免去了连续输入和牢记的烦恼 2.当你对某个函数不是很理解的时候,你可以将鼠标放在该函数上,该工具 ...
- 开始转型学习java
什么编程语言这些都是一样的,编程思想都是一样的.只不过是表现形式. 标识符 每一个字符在ascll码表例都有对应的数字 所以字符和数字是可以相加的 'a'+1 也可以显示数字对应的字符 (ch ...
- Log4j2的基本使用
Log4j2是Log4j1.x的的升级版,其中也有很大的不同,最大的区别就是由以前的properties配置文件改为xml/json/yaml配置文件. 其中配置文件的位置官方说明如下: Log4j ...
- maven学习(6)-Maven依赖范围
一.maven依赖范围: classpath 分为三种:编译classpath , 测试classpath , 运行classpath Scope 选项如下: Compile:编译依赖范围.默认就是c ...