DELPHI隐藏有一个设置控件属性的函数(把这个函数拷贝到你的程序中)
procedure SetComCtlStyle(Ctl: TWinControl; Value: Integer; UseStyle: Boolean);
var
Style: Integer;
begin
if Ctl.HandleAllocated then
begin
Style := GetWindowLong(Ctl.Handle, GWL_STYLE);
if not UseStyle then Style := Style and not Value
else Style := Style or Value;
SetWindowLong(Ctl.Handle, GWL_STYLE, Style);
end;
end;
新版的WIN公共控件的TREEVIEW中有DELPHI中没有的风格定义
const
TVS_CHECKBOXES = $0100;
用下面的语句既可给TTREEVIEW加CHECKBOX
SetComCtlStyle(TTreeView1,TVS_CHECKBOXES,True);
procedure SetComCtlStyle(Ctl: TWinControl; Value: Integer; UseStyle: Boolean);
var
Style: Integer;
begin
if Ctl.HandleAllocated then
begin
Style := GetWindowLong(Ctl.Handle, GWL_STYLE);
if not UseStyle then Style := Style and not Value
else Style := Style or Value;
SetWindowLong(Ctl.Handle, GWL_STYLE, Style);
end;
end;
新版的WIN公共控件的TREEVIEW中有DELPHI中没有的风格定义
const
TVS_CHECKBOXES = $0100;
用下面的语句既可给TTREEVIEW加CHECKBOX
SetComCtlStyle(TTreeView1,TVS_CHECKBOXES,True);
解决方案 »
- 一个简单的SQL语句问题,送分啊
- 今天普济难民,放100分
- 新手恳求dephi入门经验~~~~~~~~~~~~~~~~~~
- 如何将表达式返回 bool值
- DBGrid控件里面的表格能不能把其中某个字段格式修改为combobox。
- 请问以下如何汇总当月销售情况?
- 如何在指定目录下创建一个临时表(dbase5格式),急切需要!!!希望大家多多指教。
- 求助!谁知道delphi6.163安装时需输入的serial number和authorization key!
- 关于报表设置的一个问题(TQuickQep)
- 今天终于用上delphi6了 太高兴了!!!!!!!!
- 如何读出光盘中所有歌曲的名称?
- 优点
问一句,哪里可以找到这些详细资料?
太神了,
学习
请问该涵数是用在什么地方能让TREEVIER加CHECKBOX
你可以看看这个单元
C:\Program Files\Borland\Delphi6\Source\Rtl\Win\CommCtrl.pas
CommCtrl是Win95/98的DLL,包含了Windows的Common Controls,
比如ListView,TreeView等
那怎么样判断有没有打勾,而且可以保存这个界面
怎么没有实际用处?以下代码可以判断有没有打勾:
Uses CommCtrl;function IsNodeChecked(Node :TTreeNode) :Boolean;
const
TVIS_CHECKED = $2000;
var
TvItem :TTVItem;
begin
TvItem.Mask := TVIF_STATE;
TvItem.hItem := Node.ItemId;
TreeView_GetItem(Node.TreeView.Handle, TvItem);
Result := (TvItem.State and TVIS_CHECKED) = TVIS_CHECKED;
end;
1stClass我没有用过,我不明白你所谓的保存是什么意思,我既然能够打勾,当然可以设置是否打勾了。以下代码就可以实现:
procedure SetNodeChecked(Node :TTreeNode; Checked :Boolean);
const
TVIS_CHECKED = $2000;
var
TvItem :TTVItem;
begin
FillChar(TvItem, SizeOf(TvItem), 0);
with TvItem do begin
hItem := Node.ItemId;
Mask := TVIF_STATE;
StateMask := TVIS_STATEIMAGEMASK;
if Checked then
TvItem.State :=TVIS_CHECKED
else
TvItem.State :=TVIS_CHECKED shr 1;
TreeView_SetItem(Node.TreeView.Handle, TvItem);
end;
end;
然后重新打开,就是程序打勾的也自动会出来。
还有我觉的这个CHECKBOX的前面的框是不是很大?不过你的方法是不错的了