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(TreeView1,TVS_CHECKBOXES,True);