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 ...
随机推荐
- LeetCode Factorial Trailing Zeroes Python
Factorial Trailing Zeroes Given an integer n, return the number of trailing zeroes in n!. 题目意思: n求阶乘 ...
- python 二维list取列
b = [i[0] for i in a] # 从a中的每一行取第一个元素.
- Linux设备树
一.设备树编译 1.编译设备树:cd linux-x.xx & make dtbs,生成的dtb在目录linux-x.xx/arch/xxx/boot/dts下 2.反编译dtb,生成dts: ...
- Nginx 安装成Windows 服务方法
1. 下载nginx windows版本 http://www.nginx.org 2. 下载微软的2个工具: instsrv.exe.srvany.exe 去微软网站下载安装Windows Serv ...
- JUC线程池之 Callable和Future
Callable 和 Future 简介 Callable 和 Future 是比较有趣的一对组合.当我们需要获取线程的执行结果时,就需要用到它们.Callable用于产生结果,Future用于获取结 ...
- mysql 官方docker镜像使用教程
首先是pull image,这里我拉取的是5.x版本最新版: docker pull mysql:5 拉下来以后大可以按照官方的说明无脑启动,但是外部无法访问,所以绑定端口:docker run -- ...
- 回归cnBlogs
一.最近的想法 最近几天看了好多IT和非IT朋友的技术博客和自媒体博客,本想自己搭建一个独立博客,查了好多资料,各种方法,比如:goDaddy购买域名,利用GitHub免费空间搭博客. ...
- RedHat Enterprise Linux7.0安装Oracle12c
1. 验证 1.1 硬盘空间要求 1.1.1 安装盘 类型 占用磁盘空间 Enterprise Edition 6.4GB Standard Edition 6.1GB Standard Editio ...
- 求两点之间距离 C++
求两点之间距离(20 分) 定义一个Point类,有两个数据成员:x和y, 分别代表x坐标和y坐标,并有若干成员函数. 定义一个函数Distance(), 用于求两点之间的距离.输入格式: 输入有两行 ...
- MongoDB CPU 利用率高,分析慢请求
Jemeter 压测过程,发现mongodb的CPU均达到100%,需要查看mongodb的执行情况,使用mongo自带的profiling功能. profiling将请求的执行情况记录在DB下的 s ...