AGB  ·  Datenschutz  ·  Impressum  







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

Autocomplete (Combobox)

Ein Thema von VkPenguin · begonnen am 22. Nov 2014 · letzter Beitrag vom 26. Nov 2014
 
hathor
(Gast)

n/a Beiträge
 
#5

AW: Autocomplete (Combobox)

  Alt 25. Nov 2014, 08:56
Im Anhang Source + EXE.
Hier ist der vollständige Sourcecode:

Delphi-Quellcode:
program AutoComplete_Example;

uses
  Forms,
  Main in 'Main.pas{MainForm},
  UAutoComplete in 'UAutoComplete.pas';

{$R *.res}
{$R WindowsXP.res}

begin
  Application.Initialize;
  Application.Title := 'Example AutoComplete';
  Application.CreateForm(TMainForm, MainForm);
  Application.Run;
end.
//------------------------------------------------
unit Main;

interface

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

type
  TMainForm = class(TForm)
    InfoLbl: TLabel;
    EditControl: TEdit;
    OptionsBox: TGroupBox;
    FileBox: TCheckBox;
    HistoryBox: TCheckBox;
    RecentBox: TCheckBox;
    QuitBtn: TButton;
    SepBevel: TBevel;
    AppendBox: TCheckBox;
    procedure FormCreate(Sender: TObject);
    procedure QuitBtnClick(Sender: TObject);
    procedure OptionChange(Sender: TObject);
  private
    { Déclarations privées }
  public
    { Déclarations publiques }
  end;

var
  MainForm: TMainForm;
  Params: TCompleteParams;

implementation

{$R *.dfm}

procedure TMainForm.FormCreate(Sender: TObject);
begin
 DoubleBuffered := True;
 OptionsBox.DoubleBuffered := True;
 with Params do
  begin
   Options := [coeFileSystem,coeURLHistory,coeRecent];
   Append := True;
  end;
 if not AutoComplete(EditControl.Handle, Params) then raise
 Exception.Create('ERROR: Definition Auto-Complete');
end;

procedure TMainForm.QuitBtnClick(Sender: TObject);
begin
 Close;
end;

function ElementFromTag(Value: Integer): TCompleteOptionsElements;
begin
 case Value of
  1: Result := coeFileSystem;
  2: Result := coeURLHistory;
  3: Result := coeRecent;
  else Result := coeFileSystem;
 end;
end;

procedure TMainForm.OptionChange(Sender: TObject);
begin
 if Sender is TCheckBox then
  with TCheckBox(Sender), Params do
   begin
    if (Tag in [1..3]) then if Checked then
    Include(Options, ElementFromTag(Tag)) else Exclude(Options, ElementFromTag(Tag));
    if Tag = 4 then Append := Checked;
    if not AutoComplete(EditControl.Handle, Params) then raise
    Exception.Create('ERROR: Definition Auto-Complete');
   end;
end;

end.
//------------------------------------------------------
unit UAutoComplete;

interface

uses ComObj;

type
 Longword = Cardinal;

 TCompleteOptionsElements = (coeFileSystem, coeURLHistory, coeRecent);
 TCompleteOptions = set of TCompleteOptionsElements;

 TCompleteParams = record
  Options: TCompleteOptions;
  Append: Boolean;
 end;

function AutoComplete(Handle: Longword; Params: TCompleteParams): Boolean;

implementation

function SHAutoComplete(hwndEdit, dwFlags: Longword): Longword; stdcall; external 'shlwapi.dll';

const
 SHACF_AUTOAPPEND_FORCE_OFF = $80000000;
 SHACF_AUTOAPPEND_FORCE_ON = $40000000;
 SHACF_FILESYSTEM = $00000001;
 SHACF_URLHISTORY = $00000002;
 SHACF_URLMRU = $00000004;
 SHACF_NOAUTOCOMPLETE = $00000008;

 AppendConsts: array [Boolean] of Longword = (SHACF_AUTOAPPEND_FORCE_OFF, SHACF_AUTOAPPEND_FORCE_ON);

function CompleteOptionsToFlags(Value: TCompleteOptions): Longword;
begin
 if Value = [] then Result := SHACF_NOAUTOCOMPLETE else
  begin
   Result := 0;
   if coeFileSystem in Value then Result := Result or SHACF_FILESYSTEM;
   if coeURLHistory in Value then Result := Result or SHACF_URLHISTORY;
   if coeRecent in Value then Result := Result or SHACF_URLMRU;
  end;
end;

function AutoComplete(Handle: Longword; Params: TCompleteParams): Boolean;
begin
 with Params do Result := (SHAutoComplete(Handle, CompleteOptionsToFlags(Options) or AppendConsts[Append]) = 0);
end;

end.
Angehängte Dateien
Dateityp: zip AUTOCOMPLETE-1.zip (556,7 KB, 64x aufgerufen)

Geändert von hathor (25. Nov 2014 um 18:16 Uhr)
  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 17:42 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