AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Automatische Vervollständigung bei Eingabe?

Ein Thema von mandumoal · begonnen am 26. Sep 2003 · letzter Beitrag vom 28. Sep 2003
 
Benutzerbild von eddy
eddy

Registriert seit: 3. Jan 2003
Ort: Sachsen
573 Beiträge
 
Delphi 5 Professional
 
#11

Re: Automatische Vervollständigung bei Eingabe?

  Alt 27. Sep 2003, 17:41
Hallo mandumoal,

AutoFill für ComboBox, das hatten wir schon: DP Suche AutoFill für Combobox

Wenn das nicht weiterhilft, dann vielleicht das:
Delphi-Quellcode:
unit ComboBoxAF; //ComboBox AutoFill

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TComboBoxAF = class(TComboBox)
  private
    { Private-Deklarationen }
    FAutoFill : Boolean;
    function GetAutoFill : Boolean;
    procedure SetAutoFill(value : Boolean);
  protected
    { Protected-Deklarationen }
    procedure ComboWndProc(var Message: TMessage; ComboWnd: HWnd;
                                                  ComboProc: Pointer); override;

  public
    { Public-Deklarationen }
    constructor Create(aOwner: TComponent); override;
    Destructor Destroy; override;
  published
    { Published-Deklarationen }
    property AutoFill : Boolean read GetAutoFill write SetAutoFill;
  end;

procedure Register;

implementation

procedure TComboBoxAF.ComboWndProc(var Message: TMessage; ComboWnd: HWnd;
                                                            ComboProc: Pointer);
var
  I: Integer;
  s: String;
begin
  inherited ComboWndProc(Message, ComboWnd, ComboProc);
  if not FAutoFill then Exit;
  // first check whether the backspace key was pressed, we do not fill in
  // in such case!
  if Message.Msg = WM_CHAR then begin
    // all characters from 32 (Space) through 127 (Upper ANSI) are matched
    if TWMChar(Message).CharCode in [$20..$7F] then begin
      // fill in the rest of the text
      // save the current text, the user has typed
      s := Text;
      // get the first string, matching the text partially
      I := SendMessage(Handle, CB_FINDSTRING, -1, LongInt(PChar(s)));
      if I >= 0 then begin
        // match found!
        // load matching text, I is the position of the matching string
        Text := Items.Strings[I];
        // select the text beyond the text typed
        SelStart := Length(s);
        SelLength := Length(Text) - Length(s);
      end;
    end;
  end;
end;


function TComboBoxAF.GetAutoFill : Boolean;
begin
  Result := FAutoFill;
end;

procedure TComboBoxAF.SetAutoFill(value : Boolean);
begin
  FAutoFill := value;
end;

constructor TComboBoxAF.Create(aOwner: TComponent);
begin
  inherited Create(aOwner);
  FAutoFill := true;
  Sorted := true;
end;

Destructor TComboBoxAF.Destroy;
Begin
  inherited Destroy;
End;

procedure Register;
begin
  RegisterComponents('Beispiele', [TComboBoxAF]); //
end;

end.
Ist mein letzter Bearbeitungsstand und funktioniert.

mfg
eddy

[edit=Daniel B]Delphi-Tags korrigiert. Mfg, Daniel B[/edit]
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:10 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz