Цитата: Нужно получитать и восстанавливать позицию cxScrollBar-ов в TcxDBTreeList. Никому не доводилосю копаться в ентом ?
ну и спрятали ... партизаны:
function GetCXScrollPosition(AcxDBTreeList: TcxDBTreeList; Kind: TScrollBarKind): Integer; overload;
function SetCXScrollPosition(AcxDBTreeList: TcxDBTreeList; Kind: TScrollBarKind; Position: Integer): Boolean; overload;
[more]
uses
...
//
// cx scrollbar
//
cxControls, cxDBTL;
type
TcxDBTreeListPro = class(TcxDBTreeList)
public
property Controller;
end;
TcxControlScrollBarPro = class(TcxControlScrollBar)
end;
function GetCXScrollBar(AControl: TWinControl; Kind: TScrollBarKind): TcxControlScrollBar; overload;
var
i: Integer;
vControl: TControl;
begin
for i := 0 to AControl.ControlCount - 1 do
begin
vControl := AControl.Controls[i];
if vControl.ClassType = TcxControlScrollBar then
begin
Result := TcxControlScrollBar(vControl);
if Result.Visible and (Result.Kind = Kind) then
Exit;
end;
end;
Result := nil;
end;
function GetCXScrollBar(AcxDBTreeList: TcxDBTreeList; Kind: TScrollBarKind): TcxControlScrollBar; overload;
var
vControl: TWinControl;
begin
vControl := TcxDBTreeListPro(AcxDBTreeList).Controller.TreeList;
Result := GetCXScrollBar(vControl, Kind);
end;
function GetCXScrollPosition(AControl: TWinControl; Kind: TScrollBarKind): Integer; overload;
var
vScrollBar: TcxControlScrollBar;
begin
vScrollBar := GetCXScrollBar(AControl, Kind);
if vScrollBar <> nil then
Result := vScrollBar.Position
else
Result := -1;
end;
function GetCXScrollPosition(AcxDBTreeList: TcxDBTreeList; Kind: TScrollBarKind): Integer; overload;
var
vControl: TWinControl;
begin
vControl := TcxDBTreeListPro(AcxDBTreeList).Controller.TreeList;
Result := GetCXScrollPosition(vControl, Kind);
end;
function SetCXScrollPosition(AControl: TWinControl; Kind: TScrollBarKind; Position: Integer): Boolean; overload;
var
vScrollBar: TcxControlScrollBar;
// 2:
//vScrollPos: Integer;
begin
Result := Position >= 0;
if not Result then
Exit;
vScrollBar := GetCXScrollBar(AControl, Kind);
Result := vScrollBar <> nil;
if Result then
begin
// 1:
//
// by TcxControlScrollBar.InternalScroll(scPosition):
//
// vScrollBar.Position := Position;
// vScrollBar.Perform(CN_VSCROLL, Integer(scPosition), Position); //scPosition == SB_THUMBPOSITION
// - vScrollBar.Perform(WM_VSCROLL, SB_THUMBPOSITION, Position);// - bad variant
// ---
// 2:
//vScrollPos := Position;
TcxControlScrollBarPro(vScrollBar).Scroll(scPosition, Position);
//Result := Position = vScrollPos;
end;
end;
function SetCXScrollPosition(AcxDBTreeList: TcxDBTreeList; Kind: TScrollBarKind; Position: Integer): Boolean; overload;
// 1:
//var
// vControl: TWinControl;
begin
Result := Position >= 0;
if not Result then
Exit;
// 1:
//vControl := TcxDBTreeListPro(AcxDBTreeList).Controller.TreeList;
//Result := SetCXScrollPosition(vControl, Kind, Position);
// ---
// 2:
Result := (AcxDBTreeList <> nil);
if Result then
TcxDBTreeListPro(AcxDBTreeList).Scroll(Kind, scPosition, Position);
end;
[/more]