lcl: redo fixing issue #0016354, don't set ItemIndex = -1 after loading

git-svn-id: trunk@25095 -
This commit is contained in:
paul 2010-05-01 11:51:32 +00:00
parent db018c3342
commit f82013575c
3 changed files with 14 additions and 14 deletions

View File

@ -42,15 +42,17 @@ begin
FItems.Free; FItems.Free;
end; end;
// and use the interface based list // and use the interface based list
FItems:= NewStrings; FItems := NewStrings;
TWSCustomComboBoxClass(WidgetSetClass).SetItemIndex(Self, FItemIndex); if FItemIndex <> -1 then
TWSCustomComboBoxClass(WidgetSetClass).SetItemIndex(Self, FItemIndex);
TWSCustomComboBoxClass(WidgetSetClass).SetStyle(Self, FStyle); TWSCustomComboBoxClass(WidgetSetClass).SetStyle(Self, FStyle);
TWSCustomComboBoxClass(WidgetSetClass).SetArrowKeysTraverseList(Self, FArrowKeysTraverseList); TWSCustomComboBoxClass(WidgetSetClass).SetArrowKeysTraverseList(Self, FArrowKeysTraverseList);
TWSCustomComboBoxClass(WidgetSetClass).SetReadOnly(Self, FReadOnly); TWSCustomComboBoxClass(WidgetSetClass).SetReadOnly(Self, FReadOnly);
TWSCustomComboBoxClass(WidgetSetClass).SetMaxLength(Self, FMaxLength); TWSCustomComboBoxClass(WidgetSetClass).SetMaxLength(Self, FMaxLength);
if FSelStart <> FSelLength then begin if FSelStart <> FSelLength then
begin
ASelStart:= FSelStart; ASelStart:= FSelStart;
ASelLength:= FSelLength; ASelLength:= FSelLength;
SelStart:= ASelStart; SelStart:= ASelStart;
@ -898,10 +900,10 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TCustomComboBox.GetItemIndex : integer; function TCustomComboBox.GetItemIndex : integer;
begin begin
if not (csDestroying in ComponentState) if not (csDestroying in ComponentState) and
and not (csDestroyingHandle in ControlState) and HandleAllocated then not (csDestroyingHandle in ControlState) and HandleAllocated then
FItemIndex:= TWSCustomComboBoxClass(WidgetSetClass).GetItemIndex(Self); FItemIndex:= TWSCustomComboBoxClass(WidgetSetClass).GetItemIndex(Self);
Result:=FItemIndex; Result := FItemIndex;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------

View File

@ -375,10 +375,14 @@ begin
// restore text in edit box // restore text in edit box
UpdateComboHeight; UpdateComboHeight;
TWin32WSCustomComboBox.SetText(FSender, EditText); TWin32WSCustomComboBox.SetText(FSender, EditText);
lItemIndex := IndexOf(EditText); if EditText = '' then
lItemIndex := -1
else
lItemIndex := IndexOf(EditText);
if lItemIndex <> -1 then if lItemIndex <> -1 then
TWin32WSCustomComboBox.SetItemIndex(TCustomComboBox(FSender), lItemIndex); TWin32WSCustomComboBox.SetItemIndex(TCustomComboBox(FSender), lItemIndex);
end else end
else
inherited Assign(Source); inherited Assign(Source);
end; end;

View File

@ -858,12 +858,6 @@ end;
class function TWin32WSCustomComboBox.GetItemIndex(const ACustomComboBox: TCustomComboBox): integer; class function TWin32WSCustomComboBox.GetItemIndex(const ACustomComboBox: TCustomComboBox): integer;
begin begin
Result := SendMessage(ACustomComboBox.Handle, CB_GETCURSEL, 0, 0); Result := SendMessage(ACustomComboBox.Handle, CB_GETCURSEL, 0, 0);
if Result = LB_ERR Then
Begin
Assert(False, 'Trace:[TWin32WidgetSet.IntSendMessage3] Could not retrieve item index '+
'via LM_GETITEMINDEX; try selecting an item first');
Result := -1;
End;
end; end;
class function TWin32WSCustomComboBox.GetMaxLength(const ACustomComboBox: TCustomComboBox): integer; class function TWin32WSCustomComboBox.GetMaxLength(const ACustomComboBox: TCustomComboBox): integer;