我试图通过以下函数将TListView
控件的方向设置为:RTL
procedure RTL_LV(lv:TListView);
const
LVM_FIRST = $1000;
LVM_GETHEADER = LVM_FIRST + 31;
var
header: THandle;
begin
header:= SendMessage (lv.Handle, LVM_GETHEADER, 0, 0);
SetWindowLong (header, GWL_EXSTYLE,
GetWindowLong (header, GWL_EXSTYLE) or
WS_EX_LAYOUTRTL or WS_EX_NOINHERITLAYOUT);
SetWindowLong (lv.Handle, GWL_EXSTYLE,
GetWindowLong (lv.Handle, GWL_EXSTYLE) or
WS_EX_LAYOUTRTL or WS_EX_NOINHERITLAYOUT);
lv.invalidate;
end;
但是当项目使用时我有两个问题如下VCL Styles
:
1:Vertical scrollbar
不点击不出现。
2:当我更改 ListView 列的大小并horizontal scrollbar
单击时,会显示以下错误消息:
异常来源:Vcl.ComCtrls.TListViewStyleHook.WMMouseMove
procedure TListViewStyleHook.WMMouseMove(var Message: TWMMouse);
var
SF: TScrollInfo;
SPos: Integer;
R: TRect;
begin
if VertSliderState = tsThumbBtnVertPressed then
begin
SF.fMask := SIF_ALL;
SF.cbSize := SizeOf(SF);
GetScrollInfo(Handle, SB_VERT, SF);
ScrollPos := ScrollPos + (SF.nMax - SF.nMin) * ((Mouse.CursorPos.Y - PrevScrollPos) / VertTrackRect.Height);
PrevScrollPos := Mouse.CursorPos.Y;
if Control is TCustomListView then
begin
PostMessage(Handle, WM_VSCROLL, Integer(SmallPoint(SB_THUMBTRACK, Round(ScrollPos))), 0);
if TCustomListView(Control).ViewStyle = vsReport then
begin
if (Abs(ScrollPos - ListPos) >= 1) or
((ScrollPos = SF.nMin) and (ListPos <> ScrollPos)) or
((ScrollPos = SF.nMax) and (ListPos <> ScrollPos)) then
begin
if TCustomListView(Control).GroupView then
begin
SPos := Round(ScrollPos - ListPos);
if SF.nPos + SPos < 0 then SPos := -SF.nPos;
end
else
begin
ListView_GetItemRect(Handle, 0, R, LVIR_BOUNDS);
SPos := Round((ScrollPos - ListPos) * R.Height);
end;
ListView_Scroll(Handle, 0, SPos);
ListPos := ScrollPos;
end;
end
else
begin
if Abs(ScrollPos - ListPos) >= 1 then
begin
ListView_Scroll(Handle, 0, Round((ScrollPos - ListPos)));
ListPos := ScrollPos;
end;
end;
end
else
PostMessage(Handle, WM_VSCROLL, Integer(SmallPoint(SB_THUMBPOSITION, Round(ScrollPos))), 0);
PaintScroll;
Handled := True;
Exit;
end;
if HorzSliderState = tsThumbBtnHorzPressed then
begin
SF.fMask := SIF_ALL;
SF.cbSize := SizeOf(SF);
GeTScrollInfo(Handle, SB_HORZ, SF);
ScrollPos := ScrollPos + (SF.nMax - SF.nMin) * ((Mouse.CursorPos.X - PrevScrollPos) / HorzTrackRect.Width);
if ScrollPos < SF.nMin then
ScrollPos := SF.nMin;
if ScrollPos > SF.nMax then
ScrollPos := SF.nMax;
PrevScrollPos := Mouse.CursorPos.X;
if Control is TCustomListView then
begin
if TCustomListView(Control).ViewStyle = vsReport then
begin
if Abs(ScrollPos - ListPos) >= 1 then
begin
ListView_Scroll(Handle, Round((ScrollPos - ListPos)), 0);
ListPos := ScrollPos;
end;
end
else
begin
if Abs(ScrollPos - ListPos) >= 0.5 then
begin
ListView_Scroll(Handle, Round((ScrollPos - ListPos)), 0);
ListPos := ScrollPos;
end;
end;
end
else
PostMessage(Handle, WM_HSCROLL, Integer(SmallPoint(SB_THUMBPOSITION, Round(ScrollPos))), 0);
PaintScroll;
Handled := True;
Exit;
end;
if (HorzSliderState <> tsThumbBtnHorzPressed) and (HorzSliderState = tsThumbBtnHorzHot) then
begin
HorzSliderState := tsThumbBtnHorzNormal;
PaintScroll;
end;
if (VertSliderState <> tsThumbBtnVertPressed) and (VertSliderState = tsThumbBtnVertHot) then
begin
VertSliderState := tsThumbBtnVertNormal;
PaintScroll;
end;
if (HorzUpState <> tsArrowBtnLeftPressed) and (HorzUpState = tsArrowBtnLeftHot) then
begin
HorzUpState := tsArrowBtnLeftNormal;
PaintScroll;
end;
if (HorzDownState <> tsArrowBtnRightPressed) and (HorzDownState =tsArrowBtnRightHot) then
begin
HorzDownState := tsArrowBtnRightNormal;
PaintScroll;
end;
if (VertUpState <> tsArrowBtnUpPressed) and (VertUpState = tsArrowBtnUpHot) then
begin
VertUpState := tsArrowBtnUpNormal;
PaintScroll;
end;
if (VertDownState <> tsArrowBtnDownPressed) and (VertDownState = tsArrowBtnDownHot) then
begin
VertDownState := tsArrowBtnDownNormal;
PaintScroll;
end;
CallDefaultProc(TMessage(Message));
if LeftButtonDown then
PaintScroll;
Handled := True;
end;
这些问题应该如何解决?
谢谢。