Also das was du da machst ist äußerst seltsam. Mein Vorschlag wäre, dass du die Prozeduren in dein Formular nimmst.
Delphi-Quellcode:
Tfm_haupt = class(TForm)
...
private
procedure combobox_erstellen(Top, Left : Integer; Besitzer : TComponent);
procedure combobox_change(Sender : TObject);
procedure combobox_KeyPress(Sender : TObject; var Key: Char);
procedure combobox_KeyUp(Sender : TObject; var Key: Word; Shift: TShiftState);
end;
var
fm_haupt : Tfmhaupt;
implementation
{$R *.DFM}
procedure Tfm_haupt.combobox_erstellen(Top, Left : Integer; Besitzer : TComponent);
Var CB : TAdvComboBox;
begin
CB := TAdvComboBox.Create(Besitzer);
CB.Parent := Besitzer;
CB.Top := Top;
CB.Left := Left;
CB.Text := 'Personen-Suche';
CB.Font.Color := clGrayText;
CB.AutoComplete := false;
CB.Name := 'combo_Suche2';
CB.OnChange := combobox_change;
CB.OnKeyPress := combobox_KeyPress;
CB.OnKeyUp := combobox_KeyUp;
// CB.OnKeyDown := combobox_KeyUp;
end;
procedure Tfm_haupt.combobox_change(Sender : TObject);
begin
if TAdvComboBox(Sender).Font.Color <> clBlack
then
TAdvComboBox(Sender).Font.Color := clBlack;
end;
procedure Tfm_haupt.combobox_KeyPress(Sender : TObject; var Key: Char);
begin
label1.caption := TAdvComboBox(Sender).Text;
end;
procedure Tfm_haupt.combobox_KeyUp(Sender : TObject; var Key: Word; Shift: TShiftState);
begin
label2.caption := TAdvComboBox(Sender).Text;
end;
procedure Tfm_haupt.Button1Click(Sender: TObject);
begin
combobox_erstellen(20, 20, Panel1);
end;