Autor Beitrag
Dhakiyah
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 327
Erhaltene Danke: 5

Windows 7
Delphi XE2
BeitragVerfasst: Fr 07.09.12 09:48 
Hallo!
Ich habe in einer Combobox folgende Werte drin stehen als Beispiel (Benutzernamen):
CKlein
LMayer
UMüller
ASchmidt

etc.

So, wenn ich das Programm starte, dann stehe ich ja auf CKlein.

Im Ereignis KeyPress habe ich folgendes drin stehen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure Tfrm_dlg_anmeldung.cmb_userKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = Char(13then inp_pw.setFocus;
end;


Habe ich unter Einstellungen von der Combobox bei Style CSDropDown drin stehen passiert folgendes:
- gebe ich jetzt um ein steht in der Combobox umüller drin (es sollte aber UMüller drin stehen...)
- drücke ich TAB Taste gelange ich zur Edit Feld Passwort
- drücke ich Enter Taste gelange ich auch zum Edit Feld Passwort

Stelle ich den Style auf CSDropDownList passiert folgendes:
- gebe ich jetzt um ein, stehe ich auch auf CMüller (also das steht drin)
- drücke ich TAB Taste passiert gar nix
- drücke ich Enter gelange ich zum Edit Felt Passwort

Ich habe dann folgendes beim KeyPress dazu gefügt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure Tfrm_dlg_anmeldung.cmb_userKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = Char(13then inp_pw.setFocus;
  if Key = Char(9then
  begin
    Key := Char(13);
    inp_pw.SetFocus;
  end;

end;


Er geht dann zwar in das EditFeld Passwort, ABER dann steht er auf einmal auf CKlein, was ja vollkommen falsch ist, wenn ich die TAB Taste drücke. Beim Enter geht es...

Wie kann ich das umgehen?

Was ich möchte:
- Er soll beim Tastendruck ENTER + TAB in das EditFeld Passwort springen und soll dann immernoch auf CMüller stehen.
- Ich möchte vermeiden, dass wenn ich cm eingebe, dass dann cmüller da steht.

_________________
Es ist soooo flauschig !!!
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Fr 07.09.12 10:32 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
unit Unit6;

interface

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

  const C_PWMessage=WM_User+77;

type
  TForm6 = class(TForm)
    ComboBox1: TComboBox;
    pwedit: TEdit;
    procedure ComboBox1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    Procedure FocusPW(var M:TMessage);message C_PWMessage;
  end;

var
  Form6: TForm6;

implementation

{$R *.dfm}

procedure TForm6.ComboBox1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  if (key=vk_tab) or (key=13then
    begin
      key := 13;
      PostMessage(Handle,C_PWMessage, 10);
    end;

end;

procedure TForm6.FocusPW(var M: TMessage);
begin
    pwEdit.SetFocus;
end;

end.

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS
Dhakiyah Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 327
Erhaltene Danke: 5

Windows 7
Delphi XE2
BeitragVerfasst: Fr 07.09.12 11:11 
Ach super Danke.

Was bedeutet C_PWMessage=WM_User+77;?

_________________
Es ist soooo flauschig !!!
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Fr 07.09.12 11:20 
Eine Konstante für eine Benutzerdefinierte Message

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS