lcl-cocoa: Initial implementation for PageControl, preparation works for ListView

git-svn-id: trunk@44772 -
This commit is contained in:
sekelsenmat 2014-04-21 09:19:52 +00:00
parent fc35f675bc
commit b45ce42178
4 changed files with 472 additions and 23 deletions

View File

@ -461,7 +461,7 @@ type
function lclIsHandle: Boolean; override;
end;
TCocoaListView = objcclass;
TCocoaListBox = objcclass;
{ TCocoaStringList }
@ -469,8 +469,52 @@ type
protected
procedure Changed; override;
public
Owner: TCocoaListView;
constructor Create(AOwner: TCocoaListView);
Owner: TCocoaListBox;
constructor Create(AOwner: TCocoaListBox);
end;
{ TCocoaListBox }
TCocoaListBox = objcclass(NSTableView, NSTableViewDelegateProtocol, NSTableViewDataSourceProtocol )
public
callback: IListBoxCallback;
list: TCocoaStringList;
resultNS: NSString; //use to return values to combo
function acceptsFirstResponder: Boolean; override;
function becomeFirstResponder: Boolean; override;
function resignFirstResponder: Boolean; override;
function lclGetCallback: ICommonCallback; override;
procedure lclClearCallback; override;
function numberOfRowsInTableView(aTableView: NSTableView): NSInteger; message 'numberOfRowsInTableView:';
function tableView_shouldEditTableColumn_row(tableView: NSTableView;
tableColumn: NSTableColumn; row: NSInteger): Boolean;
message 'tableView:shouldEditTableColumn:row:';
function tableView_objectValueForTableColumn_row(tableView: NSTableView;
objectValueForTableColumn: NSTableColumn; row: NSInteger):id;
message 'tableView:objectValueForTableColumn:row:';
procedure tableViewSelectionDidChange(notification: NSNotification); message 'tableViewSelectionDidChange:';
procedure dealloc; override;
procedure resetCursorRects; override;
// mouse
procedure mouseDown(event: NSEvent); override;
// procedure mouseUp(event: NSEvent); override; This is eaten by NSTableView - worked around with NSTableViewDelegateProtocol
procedure rightMouseDown(event: NSEvent); override;
procedure rightMouseUp(event: NSEvent); override;
procedure otherMouseDown(event: NSEvent); override;
procedure otherMouseUp(event: NSEvent); override;
procedure mouseDragged(event: NSEvent); override;
procedure mouseEntered(event: NSEvent); override;
procedure mouseExited(event: NSEvent); override;
procedure mouseMoved(event: NSEvent); override;
// key
procedure keyDown(event: NSEvent); override;
procedure keyUp(event: NSEvent); override;
function lclIsHandle: Boolean; override;
end;
{ TCocoaListView }
@ -515,7 +559,6 @@ type
procedure keyDown(event: NSEvent); override;
procedure keyUp(event: NSEvent); override;
function lclIsHandle: Boolean; override;
end;
{ TCocoaGroupBox }
@ -1926,6 +1969,152 @@ begin
end;
end;
{ TCocoaListBox }
function TCocoaListBox.lclIsHandle: Boolean;
begin
Result:=true;
end;
function TCocoaListBox.acceptsFirstResponder: Boolean;
begin
Result := True;
end;
function TCocoaListBox.becomeFirstResponder: Boolean;
begin
Result := inherited becomeFirstResponder;
callback.BecomeFirstResponder;
end;
function TCocoaListBox.resignFirstResponder: Boolean;
begin
Result := inherited resignFirstResponder;
callback.ResignFirstResponder;
end;
function TCocoaListBox.lclGetCallback: ICommonCallback;
begin
Result := callback;
end;
procedure TCocoaListBox.lclClearCallback;
begin
callback := nil;
end;
function TCocoaListBox.numberOfRowsInTableView(aTableView:NSTableView): NSInteger;
begin
if Assigned(list) then
Result := list.Count
else
Result := 0;
end;
function TCocoaListBox.tableView_shouldEditTableColumn_row(tableView: NSTableView; tableColumn: NSTableColumn; row: NSInteger): Boolean;
begin
result:=false; // disable cell editing by default
end;
function TCocoaListBox.tableView_objectValueForTableColumn_row(tableView: NSTableView;
objectValueForTableColumn: NSTableColumn; row: NSInteger):id;
begin
if not Assigned(list) then
Result:=nil
else begin
if row>=list.count then Result:=nil
else
begin
resultNS.release; //so we can reuse it
resultNS := NSStringUtf8(list[row]);
Result:= ResultNS;
end;
end;
end;
procedure TCocoaListBox.dealloc;
begin
FreeAndNil(list);
resultNS.release;
inherited dealloc;
end;
procedure TCocoaListBox.resetCursorRects;
begin
if not callback.resetCursorRects then
inherited resetCursorRects;
end;
procedure TCocoaListBox.tableViewSelectionDidChange(notification: NSNotification);
begin
if Assigned(callback) then
callback.SelectionChanged;
end;
procedure TCocoaListBox.mouseDown(event: NSEvent);
begin
if not Assigned(callback) or not callback.MouseUpDownEvent(event) then
inherited mouseDown(event);
end;
procedure TCocoaListBox.rightMouseDown(event: NSEvent);
begin
if not Assigned(callback) or not callback.MouseUpDownEvent(event) then
inherited rightMouseDown(event);
end;
procedure TCocoaListBox.rightMouseUp(event: NSEvent);
begin
if not Assigned(callback) or not callback.MouseUpDownEvent(event) then
inherited rightMouseUp(event);
end;
procedure TCocoaListBox.otherMouseDown(event: NSEvent);
begin
if not Assigned(callback) or not callback.MouseUpDownEvent(event) then
inherited otherMouseDown(event);
end;
procedure TCocoaListBox.otherMouseUp(event: NSEvent);
begin
if not Assigned(callback) or not callback.MouseUpDownEvent(event) then
inherited otherMouseUp(event);
end;
procedure TCocoaListBox.mouseDragged(event: NSEvent);
begin
if not Assigned(callback) or not callback.MouseMove(event) then
inherited mouseDragged(event);
end;
procedure TCocoaListBox.mouseEntered(event: NSEvent);
begin
inherited mouseEntered(event);
end;
procedure TCocoaListBox.mouseExited(event: NSEvent);
begin
inherited mouseExited(event);
end;
procedure TCocoaListBox.mouseMoved(event: NSEvent);
begin
inherited mouseMoved(event);
end;
procedure TCocoaListBox.keyDown(event: NSEvent);
begin
if not Assigned(callback) or not callback.KeyEvent(event) then
inherited keyDown(event);
end;
procedure TCocoaListBox.keyUp(event: NSEvent);
begin
if not Assigned(callback) or not callback.KeyEvent(event) then
inherited keyUp(event);
end;
{ TCocoaListView }
function TCocoaListView.lclIsHandle: Boolean;
@ -2080,7 +2269,7 @@ begin
Owner.reloadData;
end;
constructor TCocoaStringList.Create(AOwner:TCocoaListView);
constructor TCocoaStringList.Create(AOwner:TCocoaListBox);
begin
Owner:=AOwner;
inherited Create;

View File

@ -6,12 +6,14 @@ interface
{$modeswitch objectivec1}
uses
CocoaAll
, LCLType
, WSComCtrls
, Controls, ComCtrls
, CocoaPrivate
, CocoaWSCommon;
// RTL, FCL, LCL
CocoaAll,
Classes, LCLType, SysUtils,
Controls, ComCtrls, Types, StdCtrls, LCLProc, Graphics, ImgList,
// WS
WSComCtrls,
// Cocoa WS
CocoaPrivate, CocoaUtils, CocoaWSCommon;
type
@ -25,6 +27,110 @@ type
//class procedure Update(const AStatusBar: TStatusBar); override;
end;
{ TCocoaWSTabSheet }
TCocoaWSTabSheet = class(TWSTabSheet)
published
end;
{ TCocoaWSCustomPage }
TCocoaWSCustomPage = class(TWSCustomPage)
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure UpdateProperties(const ACustomPage: TCustomPage); override;
end;
{ TCocoaWSCustomTabControl }
TCocoaWSCustomTabControl = class(TWSCustomTabControl)
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure AddPage(const ATabControl: TCustomTabControl; const AChild: TCustomPage; const AIndex: integer); override;
class procedure MovePage(const ATabControl: TCustomTabControl; const AChild: TCustomPage; const NewIndex: integer); override;
class procedure RemovePage(const ATabControl: TCustomTabControl; const AIndex: integer); override;
//class function GetNotebookMinTabHeight(const AWinControl: TWinControl): integer; override;
//class function GetNotebookMinTabWidth(const AWinControl: TWinControl): integer; override;
//class function GetPageRealIndex(const ATabControl: TCustomTabControl; AIndex: Integer): Integer; override;
class function GetTabIndexAtPos(const ATabControl: TCustomTabControl; const AClientPos: TPoint): integer; override;
class procedure SetPageIndex(const ATabControl: TCustomTabControl; const AIndex: integer); override;
//class procedure SetTabPosition(const ATabControl: TCustomTabControl; const ATabPosition: TTabPosition); override;
//class procedure ShowTabs(const ATabControl: TCustomTabControl; AShowTabs: boolean); override;
end;
{ TCocoaWSPageControl }
TCocoaWSPageControl = class(TWSPageControl)
published
end;
{ TCocoaWSCustomListView }
TCocoaWSCustomListView = class(TWSCustomListView)
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
(* // Column
class procedure ColumnDelete(const ALV: TCustomListView; const AIndex: Integer); override;
class function ColumnGetWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn): Integer; override;
class procedure ColumnInsert(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn); override;
class procedure ColumnMove(const ALV: TCustomListView; const AOldIndex, ANewIndex: Integer; const AColumn: TListColumn); override;
class procedure ColumnSetAlignment(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AAlignment: TAlignment); override;
class procedure ColumnSetAutoSize(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AAutoSize: Boolean); override;
class procedure ColumnSetCaption(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const ACaption: String); override;
class procedure ColumnSetImage(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AImageIndex: Integer); override;
class procedure ColumnSetMaxWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AMaxWidth: Integer); override;
class procedure ColumnSetMinWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AMinWidth: integer); override;
class procedure ColumnSetWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AWidth: Integer); override;
class procedure ColumnSetVisible(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AVisible: Boolean); override;
// Item
class procedure ItemDelete(const ALV: TCustomListView; const AIndex: Integer); override;
class function ItemDisplayRect(const ALV: TCustomListView; const AIndex, ASubItem: Integer; ACode: TDisplayCode): TRect; override;
class function ItemGetChecked(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem): Boolean; override;
class function ItemGetPosition(const ALV: TCustomListView; const AIndex: Integer): TPoint; override;
class function ItemGetState(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState; out AIsSet: Boolean): Boolean; override; // returns True if supported
class procedure ItemInsert(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem); override;
class procedure ItemSetChecked(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const AChecked: Boolean); override;
//class procedure ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const {%H-}ASubIndex, {%H-}AImageIndex: Integer); override;
//carbon//class function ItemSetPosition(const ALV: TCustomListView; const AIndex: Integer; const ANewPosition: TPoint): Boolean; override;
class procedure ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean); override;
class procedure ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const {%H-}ASubIndex: Integer; const {%H-}AText: String); override;
class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const PartialOK: Boolean); override;
// LV
//carbon//class procedure BeginUpdate(const ALV: TCustomListView); override;
//carbon//class procedure EndUpdate(const ALV: TCustomListView); override;
class function GetBoundingRect(const ALV: TCustomListView): TRect; override;
//carbon//class function GetDropTarget(const ALV: TCustomListView): Integer; override;
class function GetFocused(const ALV: TCustomListView): Integer; override;
//carbon//class function GetHoverTime(const ALV: TCustomListView): Integer; override;
class function GetItemAt(const ALV: TCustomListView; x,y: integer): Integer; override;
class function GetSelCount(const ALV: TCustomListView): Integer; override;
//carbon//class function GetSelection(const ALV: TCustomListView): Integer; override;
class function GetTopItem(const ALV: TCustomListView): Integer; override;
class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; override;
//carbon//class procedure SetAllocBy(const ALV: TCustomListView; const AValue: Integer); override;
class procedure SetDefaultItemHeight(const ALV: TCustomListView; const AValue: Integer); override;
//carbon//class procedure SetHotTrackStyles(const ALV: TCustomListView; const AValue: TListHotTrackStyles); override;
//carbon//class procedure SetHoverTime(const ALV: TCustomListView; const AValue: Integer); override;
class procedure SetImageList(const ALV: TCustomListView; const {%H-}AList: TListViewImageList; const {%H-}AValue: TCustomImageList); override;
class procedure SetItemsCount(const ALV: TCustomListView; const Avalue: Integer); override;
class procedure SetOwnerData(const ALV: TCustomListView; const {%H-}AValue: Boolean); override;
class procedure SetProperty(const ALV: TCustomListView; const AProp: TListViewProperty; const AIsSet: Boolean); override;
class procedure SetProperties(const ALV: TCustomListView; const AProps: TListViewProperties); override;
class procedure SetScrollBars(const ALV: TCustomListView; const AValue: TScrollStyle); override;
class procedure SetSort(const ALV: TCustomListView; const {%H-}AType: TSortType; const {%H-}AColumn: Integer;
const {%H-}ASortDirection: TSortDirection); override;
class procedure SetViewOrigin(const ALV: TCustomListView; const AValue: TPoint); override;
class procedure SetViewStyle(const ALV: TCustomListView; const AValue: TViewStyle); override;*)
end;
{ TCocoaWSProgressBar }
TCocoaWSProgressBar = class(TWSProgressBar)
@ -40,6 +146,25 @@ implementation
type
TCocoaTabPage = objcclass(NSTabViewItem)
callback: ICommonCallback;
LCLPage: TCustomPage;
//function lclGetCallback: ICommonCallback; override;
//procedure lclClearCallback; override;
end;
TCocoaTabControl = objcclass(NSTabView)
callback: ICommonCallback;
//function lclGetCallback: ICommonCallback; override;
//procedure lclClearCallback; override;
end;
TCocoaTableListView = objcclass(NSTableView)
callback: ICommonCallback;
//function lclGetCallback: ICommonCallback; override;
//procedure lclClearCallback; override;
end;
{ TCocoaProgressIndicator }
TCocoaProgressIndicator = objcclass(NSProgressIndicator)
@ -65,6 +190,115 @@ begin
end;
end;
{ TCocoaWSCustomPage }
class function TCocoaWSCustomPage.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
var
lControl: TCocoaTabPage;
begin
lControl := TCocoaTabPage.alloc().init();
Result := TLCLIntfHandle(lControl);
if Result <> 0 then
begin
//lControl.callback := TLCLCommonCallback.Create(Result, ATarget);
lControl.LCLPage := TCustomPage(AWinControl);
end;
end;
class procedure TCocoaWSCustomPage.UpdateProperties(const ACustomPage: TCustomPage);
begin
end;
{ TCocoaWSCustomTabControl }
class function TCocoaWSCustomTabControl.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
var
lControl: TCocoaTabPage;
begin
lControl := TCocoaTabControl.alloc.lclInitWithCreateParams(AParams);
Result := TLCLIntfHandle(lControl);
if Result <> 0 then
begin
//Result.callback := TLCLCommonCallback.Create(Result, ATarget);
end;
end;
class procedure TCocoaWSCustomTabControl.AddPage(const ATabControl: TCustomTabControl; const AChild: TCustomPage; const AIndex: integer);
var
lTabControl: TCocoaTabControl;
lTabPage: TCocoaTabPage;
begin
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
lTabControl := TCocoaTabControl(ATabControl.Handle);
if not Assigned(AChild) or not AChild.HandleAllocated then Exit;
lTabPage := TCocoaTabPage(AChild.Handle);
lTabControl.insertTabViewItem_atIndex(lTabPage, AIndex);
end;
class procedure TCocoaWSCustomTabControl.MovePage(const ATabControl: TCustomTabControl; const AChild: TCustomPage; const NewIndex: integer);
var
lTabControl: TCocoaTabControl;
lTabPage: TCocoaTabPage;
begin
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
lTabControl := TCocoaTabControl(ATabControl.Handle);
if not Assigned(AChild) or not AChild.HandleAllocated then Exit;
lTabPage := TCocoaTabPage(AChild.Handle);
lTabControl.removeTabViewItem(lTabPage);
lTabControl.insertTabViewItem_atIndex(lTabPage, NewIndex);
end;
class procedure TCocoaWSCustomTabControl.RemovePage(const ATabControl: TCustomTabControl; const AIndex: integer);
var
lTabControl: TCocoaTabControl;
lTabPage: NSTabViewItem;
begin
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
lTabControl := TCocoaTabControl(ATabControl.Handle);
lTabPage := lTabControl.tabViewItemAtIndex(AIndex);
lTabControl.removeTabViewItem(lTabPage);
end;
class function TCocoaWSCustomTabControl.GetTabIndexAtPos(const ATabControl: TCustomTabControl; const AClientPos: TPoint): integer;
var
lTabControl: TCocoaTabControl;
lTabPage: NSTabViewItem;
lClientPos: NSPoint;
begin
Result := 0;
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
lTabControl := TCocoaTabControl(ATabControl.Handle);
lClientPos := GetNSPoint(AClientPos.X, AClientPos.Y); // ToDo: Check if it doesn't need y invertion
lTabPage := lTabControl.tabViewItemAtPoint(lClientPos);
Result := lTabControl.indexOfTabViewItem(lTabPage);
end;
class procedure TCocoaWSCustomTabControl.SetPageIndex(const ATabControl: TCustomTabControl; const AIndex: integer);
var
lTabControl: TCocoaTabControl;
lTabCount: NSInteger;
begin
WriteLn('[TCocoaWSCustomTabControl.SetPageIndex]');
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
lTabControl := TCocoaTabControl(ATabControl.Handle);
WriteLn(Format('[TCocoaWSCustomTabControl.SetPageIndex] lTabControl=%d', [PtrUInt(lTabControl)]));
lTabCount := lTabControl.numberOfTabViewItems();
WriteLn(Format('[TCocoaWSCustomTabControl.SetPageIndex] lTabCount=%d', [lTabCount]));
if (AIndex < 0) or (AIndex >= lTabCount) then Exit;
lTabControl.selectTabViewItemAtIndex(AIndex);
end;
{ TCocoaWSCustomListView }
class function TCocoaWSCustomListView.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
begin
end;
{ TCocoaWSProgressBar }
class function TCocoaWSProgressBar.CreateHandle(const AWinControl: TWinControl;
@ -100,6 +334,30 @@ begin
NSProgressIndicator(AProgressBar.Handle).setIndeterminate(NewStyle = pbstMarquee);
end;
{ TCocoaTabPage }
(*function TCocoaTabPage.lclGetCallback: ICommonCallback;
begin
Result:=callback;
end;
procedure TCocoaTabPage.lclClearCallback;
begin
callback:=nil;
end;
{ TCocoaTabControl }
function TCocoaTabControl.lclGetCallback: ICommonCallback;
begin
Result:=callback;
end;
procedure TCocoaTabControl.lclClearCallback;
begin
callback:=nil;
end; *)
{ TCocoaProgressIndicator }
function TCocoaProgressIndicator.acceptsFirstResponder: Boolean;

View File

@ -165,7 +165,8 @@ end;
function RegisterPageControl: Boolean; alias : 'WSRegisterPageControl';
begin
Result := False;
RegisterWSComponent(TCustomTabControl, TCocoaWSCustomTabControl);
Result := True;
end;
function RegisterCustomListView: Boolean; alias : 'WSRegisterCustomListView';
@ -331,7 +332,8 @@ end;
// extctrls
function RegisterCustomPage: Boolean; alias : 'WSRegisterCustomPage';
begin
Result := False;
RegisterWSComponent(TCustomPage, TCocoaWSCustomPage);
Result := True;
end;
function RegisterCustomNotebook: Boolean; alias : 'WSRegisterCustomNotebook';

View File

@ -911,21 +911,21 @@ end;
{ TCocoaWSCustomListBox }
function GetListView(AWinControl: TWinControl): TCocoaListView;
function GetListBox(AWinControl: TWinControl): TCocoaListBox;
begin
if not Assigned(AWinControl) or (AWinControl.Handle=0) then
Result := nil
else
Result := TCocoaListView(TCocoaScrollView(AWinControl.Handle).documentView);
Result := TCocoaListBox(TCocoaScrollView(AWinControl.Handle).documentView);
end;
class function TCocoaWSCustomListBox.CreateHandle(const AWinControl:TWinControl;
const AParams:TCreateParams):TLCLIntfHandle;
var
list : TCocoaListView;
list : TCocoaListBox;
scroll : TCocoaScrollView;
begin
list := NSView(TCocoaListView.alloc).lclInitWithCreateParams(AParams);
list := NSView(TCocoaListBox.alloc).lclInitWithCreateParams(AParams);
if not Assigned(list) then
begin
Result := 0;
@ -954,9 +954,9 @@ end;
class function TCocoaWSCustomListBox.GetStrings(const ACustomListBox: TCustomListBox):TStrings;
var
view : TCocoaListView;
view : TCocoaListBox;
begin
view:=GetListView(ACustomListBox);
view:=GetListBox(ACustomListBox);
if not Assigned(view) then
Result:=nil
else
@ -964,12 +964,12 @@ begin
end;
class function TCocoaWSCustomListBox.GetItemRect(const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect): boolean;
var view : TCocoaListView;
var view : TCocoaListBox;
r:NSRect;
begin
Result := False;
view:=GetListView(ACustomListBox);
view:=GetListBox(ACustomListBox);
if not Assigned(view) then
begin
Result:=false;
@ -984,11 +984,11 @@ end;
class function TCocoaWSCustomListBox.GetItemIndex(const ACustomListBox: TCustomListBox): integer;
var
view : TCocoaListView;
view : TCocoaListBox;
indexset: NSIndexSet;
begin
view:=GetListView(ACustomListBox);
view:=GetListBox(ACustomListBox);
if not Assigned(view) then
begin
Result:=-1;