以下是实现查询的 combobox中的数据要从注册表读HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedUrls begin RegisterComponents('Samples', [TIEComboBox]); end;{ TIEComboBox }constructor TIEComboBox.Create(AOwner: TComponent); begin inherited; HasLeadChr:=false; FSmartInput:=true; end;procedure TIEComboBox.KeyPress(var Key: Char); var i,j,t:Integer; s:string; found:Boolean; begin Inherited; if FSmartInput then begin Found:=false; if (Key in LeadBytes) and (not HasLeadChr) then begin HasLeadChr:=true; LeadChr:=Key; Key:=#0; end else //Double Byte support if HasLeadChr or ((Key >=#32) and (Key<=#126)) then begin if HasLeadChr then begin s:=LeadChr+Key; HasLeadChr:=false; end else s:=Key; t:=SelStart; Text:=Copy(Text,1,SelStart)+Copy(Text,SelStart+SelLength+1,Length(Text)-SelLength-1); for i:=0 to items.Count-1 do begin if Pos(Text+s,items[i])=1 then begin j:=Length(Text); Text:=items[i]; SelStart:=j+Length(s); SelLength:=Length(Text)-j; Found:=True; if Assigned(FOnSmartInputed) then FOnSmartInputed(Self); Break; end; end; if not Found then begin Text:=Copy(Text,1,t)+s+Copy(Text,t+1,Length(Text)-t+1); SelStart:=t+Length(s); end; Key:=#0; end; end; end; procedure TIEComboBox.SetOnSmartInputed(const Value: TNotifyEvent); begin FOnSmartInputed := Value; end;procedure TIEComboBox.SetSmartInput(const Value: Boolean); begin FSmartInput := Value; end;
combobox中的数据要从注册表读HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedUrls
begin
RegisterComponents('Samples', [TIEComboBox]);
end;{ TIEComboBox }constructor TIEComboBox.Create(AOwner: TComponent);
begin
inherited;
HasLeadChr:=false;
FSmartInput:=true;
end;procedure TIEComboBox.KeyPress(var Key: Char);
var
i,j,t:Integer;
s:string;
found:Boolean;
begin
Inherited;
if FSmartInput then
begin
Found:=false;
if (Key in LeadBytes) and (not HasLeadChr) then
begin
HasLeadChr:=true;
LeadChr:=Key;
Key:=#0;
end
else //Double Byte support
if HasLeadChr or ((Key >=#32) and (Key<=#126)) then
begin
if HasLeadChr then
begin
s:=LeadChr+Key;
HasLeadChr:=false;
end
else
s:=Key;
t:=SelStart;
Text:=Copy(Text,1,SelStart)+Copy(Text,SelStart+SelLength+1,Length(Text)-SelLength-1);
for i:=0 to items.Count-1 do
begin
if Pos(Text+s,items[i])=1 then
begin
j:=Length(Text);
Text:=items[i];
SelStart:=j+Length(s);
SelLength:=Length(Text)-j;
Found:=True;
if Assigned(FOnSmartInputed) then FOnSmartInputed(Self);
Break;
end;
end;
if not Found then
begin
Text:=Copy(Text,1,t)+s+Copy(Text,t+1,Length(Text)-t+1);
SelStart:=t+Length(s);
end;
Key:=#0;
end;
end;
end;
procedure TIEComboBox.SetOnSmartInputed(const Value: TNotifyEvent);
begin
FOnSmartInputed := Value;
end;procedure TIEComboBox.SetSmartInput(const Value: Boolean);
begin
FSmartInput := Value;
end;