首页 > 解决方案 > 在 RightToLeft bidimode 的右侧放置垂直滚动条的 Virtual TreeView 问题

问题描述

我使用以下代码将 VirtualTreeView 垂直滚动条放置在 RightToLeft bidimode 的右侧,并将其放置在 LeftToRight 模式的左侧。

procedure TForm1.Button2Click(Sender: TObject);
const
  LSB = WS_EX_LEFTSCROLLBAR;
var
  ExStyle: LONG_PTR;
begin
  ExStyle := GetWindowLongPtr(AVTV.Handle, GWL_EXSTYLE);

  // Check if RTL alignment specified for you component
  if AVTV.BiDiMode = bdRightToLeft then
  begin
    // If so, then exclude LSB-constant and allow Windows place 
    // scrollbar on the right side of window
    if (ExStyle and LSB) = LSB then
      SetWindowLongPtr(AVTV.Handle, GWL_EXSTYLE, ExStyle and not LSB);
  end
  else
  if AVTV.BiDiMode = bdLeftToRight then
  begin
    // The same as operation above but for LTR order
    if (ExStyle and LSB) <> LSB then
      SetWindowLongPtr(AVTV.Handle, GWL_EXSTYLE, ExStyle or LSB);
  end;
end;

它可以正常工作,但是当树处于网格模式并具有标题列时会出现问题。请看截图:

在此处输入图像描述

标签: delphivirtualtreeview

解决方案


推荐阅读