lcl: move Lookup initialization from InitializeWnd to Loaded. Just update Items address in InitializeWnd. This allows KeyValue work between Loaded and handle creation

git-svn-id: trunk@34724 -
This commit is contained in:
blikblum 2012-01-13 00:35:34 +00:00
parent 5010a42914
commit 7ebde037c3
3 changed files with 19 additions and 2 deletions

View File

@ -160,6 +160,7 @@ Type
function GetKeyValue(ValueIndex: Integer): Variant; function GetKeyValue(ValueIndex: Integer): Variant;
function GetKeyIndex: Integer; function GetKeyIndex: Integer;
function GetKeyIndex(const AKeyValue: Variant): Integer; function GetKeyIndex(const AKeyValue: Variant): Integer;
property ControlItems: TStrings read FControlItems write FControlItems;
property LookupCache: boolean read FLookupCache write SetLookupCache; property LookupCache: boolean read FLookupCache write SetLookupCache;
// properties to be published by owner control // properties to be published by owner control
// these are not used where data control Field is dbLookup // these are not used where data control Field is dbLookup
@ -441,6 +442,7 @@ Type
procedure DoSelectionChange(User: Boolean); override; procedure DoSelectionChange(User: Boolean); override;
procedure InitializeWnd; override; procedure InitializeWnd; override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override; procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure Loaded; override;
procedure UpdateData(Sender: TObject); override; procedure UpdateData(Sender: TObject); override;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
@ -762,6 +764,7 @@ Type
procedure CloseUp; override; procedure CloseUp; override;
procedure InitializeWnd; override; procedure InitializeWnd; override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override; procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure Loaded; override;
procedure UpdateData(Sender: TObject); override; procedure UpdateData(Sender: TObject); override;
procedure DataChange(Sender: TObject); override; procedure DataChange(Sender: TObject); override;
procedure Select; override; procedure Select; override;

View File

@ -79,10 +79,17 @@ begin
inherited KeyDown(Key, Shift); inherited KeyDown(Key, Shift);
end; end;
procedure TDBLookupComboBox.Loaded;
begin
inherited Loaded;
UpdateLookup;
end;
procedure TDBLookupComboBox.InitializeWnd; procedure TDBLookupComboBox.InitializeWnd;
begin begin
inherited InitializeWnd; inherited InitializeWnd;
UpdateLookup; //after handle allocation Items address changes
FLookup.ControlItems := Items;
end; end;
function TDBLookupComboBox.GetKeyField: string; function TDBLookupComboBox.GetKeyField: string;

View File

@ -62,7 +62,8 @@ end;
procedure TDBLookupListBox.InitializeWnd; procedure TDBLookupListBox.InitializeWnd;
begin begin
inherited InitializeWnd; inherited InitializeWnd;
UpdateLookup; //after handle allocation Items address changes
FLookup.ControlItems := Items;
end; end;
procedure TDBLookupListBox.KeyDown(var Key: Word; Shift: TShiftState); procedure TDBLookupListBox.KeyDown(var Key: Word; Shift: TShiftState);
@ -77,6 +78,12 @@ begin
inherited KeyDown(Key, Shift); inherited KeyDown(Key, Shift);
end; end;
procedure TDBLookupListBox.Loaded;
begin
inherited Loaded;
UpdateLookup;
end;
function TDBLookupListBox.GetKeyField: string; function TDBLookupListBox.GetKeyField: string;
begin begin
Result := FLookup.KeyField; Result := FLookup.KeyField;