2026年9月17日 星期四

ListView


//取CheckBox寬度
function GetListViewCheckboxWidth: Integer;
begin
  // SM_CXMENUCHECK 傳回選單與清單控制項中 Checkbox 的寬度(像素)
  Result := GetSystemMetrics(SM_CXMENUCHECK);
end;

//取單列的高度
function GetItemHeightSimple(AListView: TListView): Integer;
var
  R: TRect;
begin
  Result := 0;
  if AListView.Items.Count > 0 then
  begin
    // drBounds 相當於 LVIR_BOUNDS
    R := AListView.Items[0].DisplayRect(drBounds);
    Result := R.Bottom - R.Top;
  end;
end;

//取垂直ScrollBar的寬度
ScrollBarWidth := GetSystemMetrics(SM_CXVSCROLL);