我使用以下代码将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;
它可以正常工作,但是当树处于网格模式并且具有标题列时会出现问题。请查看屏幕截图: