EControl Ltd. Forum Index EControl Ltd.
VCL libraries and software support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How it's planned to get AutoComplete list number?

 
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor
View previous topic :: View next topic  
Author Message
sepa



Joined: 06 May 2007
Posts: 13

PostPosted: Sun Dec 09, 2007 6:04 am    Post subject: How it's planned to get AutoComplete list number? Reply with quote

I'm interesting how to get number of curent selected line in ACP onChange event. I see in AutoComplete demo of v2.40 such code:
Code:

  with AutoCompletePopup1.ListBox do
    if ItemIndex = -1 then Idx := -1
      else Idx := integer(Items.Objects[ItemIndex]);
  if Idx <> -1 then
    AutoCompletePopup1.ToolHint.Text := AutoCompletePopup1.Items[Idx]
  else
    AutoCompletePopup1.ToolHint.Text := '';

But it doesn't work, integer(object) allways = 0. Because you have TList.text:=TList.text in renderer without passing objects.

So question is: is it planned to get listbox.objects property work? or this was only draft and nothing will be changed?
Now i have to:
Code:

  if AutoCompletePopup1.ListBox.ItemIndex <> -1 then
    s := AutoCompletePopup1.GetListItem(AutoCompletePopup1.ListBox.ItemIndex);
    i:=AutoCompletePopup1.Items.IndexOf(s);

but there will be more better if it was in onChange parameters, something like
Code:

procedure TfmMain.AutoCompletePopup1Change(Sender: TObject; const num: integer);

=)
Back to top
View user's profile Send private message Visit poster's website
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Sun Dec 30, 2007 9:09 am    Post subject: Reply with quote

Yes, ListBox.Items.Objects[] does not contain anything and even ListBox.Items does not contain any items. In last version (2.40) virtual items are used, i.e. without filling ListBox.Items at all.

To resolve problem with indexes:
In ec_PopupCtrl.pas add public method:

Code:
function TAutoCompletePopup.ListItemIndex(ListIndex: integer): integer;
begin
  Result := FComplRender.MapIndex(ListIndex);
end;


So code in AutoComplete demo will be:

Code:
procedure TForm4.AutoCompletePopup1Change(Sender: TObject);
var Idx: integer;
begin
  with AutoCompletePopup1.ListBox do
    if ItemIndex = -1 then Idx := -1
      else Idx := AutoCompletePopup1.ListItemIndex(ItemIndex);
  if Idx <> -1 then
    AutoCompletePopup1.ToolHint.Text := AutoCompletePopup1.Items[Idx]
  else
    AutoCompletePopup1.ToolHint.Text := '';
end;


Using TAutoCompletePopup.ListBox.Items is not recommended, because this list is empty (except Delphi 5 where virtual list boxes are not supported).

Michael.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group