Ok hier die neue funktionierende Version.
Delphi-Quellcode:
procedure TSkinListView.SetTopItem(hwndLV: HWND; nItem: Integer);
var
lvItemsPerPage: Integer;
lvTopIndex: Integer;
begin
lvTopIndex := ListView_GetTopIndex(hwndLV) + 1;
lvItemsPerPage := ListView_GetCountPerPage(hwndLV);
if lvTopIndex > nItem then
ListView_EnsureVisible(hwndLV, nItem, false)
else
if (nItem - lvTopIndex) >= lvItemsPerPage then
begin
if (nItem + lvItemsPerPage) > ListView_GetItemCount(hwndLV)-1 then
ListView_EnsureVisible(hwndLV, ListView_GetItemCount(hwndLV)-1, false)
else
ListView_EnsureVisible(hwndLV, nItem + lvItemsPerPage - 1, false);
end;
if Visible then
SetFocus(hwndLV);
end;
falls es mal jemand braucht.
gruss