我的主頁: http://www.tommstudio.com/
下面的代碼可以讓Treeview前面顯示CheckBox.
const
TVS_CHECKBOXES = $00000100;
procedure SetComCtrlStyle(WinCtrl: TWinControl; Value: Integer; UseStyle: Boolean);
var
Style: Integer;
begin
if WinCtrl.HandleAllocated then
begin
Style := GetWindowLong(WinCtrl.Handle, GWL_STYLE);
if not UseStyle then
Style := Style and not Value
else Style := Style or Value;
SetWindowLong(WinCtrl.Handle, GWL_STYLE, Style);
end;
end;
SetComCtrlStyle(TreeView1, TVS_CHECKBOXES, True);
SetWindowLong(TreeView1.Handle, GWL_STYLE, GetWindowLong(TreeView1.Handle, GWL_STYLE) or $00000100);