怎么让TreeView前面显示CheckBox

时间:2010-01-30 08:19:38  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:00100;procedure SetComCtrlStyle(WinCtrl: TWinControl; Value: Integer; UseStyle: Boolean);varStyle: Integer;begin  if WinCtrl.HandleAllocated then  begin    Style := GetWindowLong(WinCtrl.Handle, GWL_STYLE);    if not UseStyle then &nbs...
  正文:下面的代码可以让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;

然后 在 OnCreate 调用:

SetComCtrlStyle(TreeView1, TVS_CHECKBOXES, True);


或者干脆简单点,一句话完事:

SetWindowLong(TreeView1.Handle, GWL_STYLE, GetWindowLong(TreeView1.Handle, GWL_STYLE) or $00000100);
怎么让TreeView前面显示CheckBox》由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Language/Delphi/12611.html


关键字:

关于《怎么让TreeView前面显示CheckBox》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td