Autor Beitrag
Moritz M.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: Mi 02.10.02 16:10 
Hi

Wie kann ich es machen, dass beim Trücken verschiederner Tasten(kombinationen) eine Prozedur oder ähnliches aufgerufen wird?
Und wie mache Ich es dass in einem eingabefeld beim drücken von Enter der Submit-Button gedrückt wird? Wie bei HTML-Forms

cu

Onz
majolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 334

Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
BeitragVerfasst: Mi 02.10.02 16:36 
Hallo

Onz hat folgendes geschrieben:


Und wie mache Ich es dass in einem eingabefeld beim drücken von Enter der Submit-Button gedrückt wird? Wie bei HTML-Forms


Also es gibt mehrere Möglichkeiten.Die einfachste ist die Eigenschaft Default auf True zu setzen.
Die zweite, wo wir auch dein erstes Problem mit einschließen können ist die Verwendung der VirtualKeys. Eine Auflistung findest du unter:
grundlagen.delphi-so...e.de/codes/vks.shtml
Diese müssen in das OnKeyDown oder OnKeyUp Ereignis des Objekts geschrieben werden.BSP ListBox:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
procedure TFRM_GroupView.ListBox1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if Key = VK_DELETE then
     Showmessage('Hallo Welt');
end;

Blödes Beispiel mir fiel nur kein Besseres ein.Aber so ist es aufgebaut.
Gruss
majolo[/url]
Moritz M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: Mi 02.10.02 16:39 
thanks
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mi 02.10.02 16:39 
ja das mit dem default ding ist schon komfortabel !!!!

aber ich hätte da mal ne frage:
ich habe in einer toolbar kompo zwei eingabe felder und einen toolbutton.
wie kann ich den toolbuttun bei [enter] automatisch drücken lassen ???
Bei ToolButtons gibt es nämlich kein Default !!!

_________________
In the beginning was the word.
And the word was content-type: text/plain.
majolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 334

Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
BeitragVerfasst: Mi 02.10.02 16:45 
Hat der die Eigenschaften ONkeyup down. Dann kannst du es mit den Virtuellen Tasten versuchen.Ich meine micht jedoch erinnern zu können,dass der die Eigenschaft nicht hat.Oder?Bin mir nicht sicher.leider auf die schnelle keine Lösung.
Gruss
majolo
JacFab
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 111



BeitragVerfasst: So 13.10.02 12:33 
Wie kann ich herausbekommen, ob ein key gedrückt ist, ohne die mousedown funktion?
also zum beispiel mit einem timer, der regelmäßig abfragt, ob die alt oder enter- taste gedrückt ist!
Moritz M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: So 13.10.02 12:37 
Titel: Hi
Hi

Ich habe mal auf swissdelphicenter.ch nachgeschaut(ne gute Seite!) und habe da folgende Lösung gefunden. Sie erzeugt einen Systemweiten HotKey:

ausblenden volle Höhe 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:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:

  The following example demonstrates registering hot keys with the 
  system to globally trap keys. 

  Das Folgende Beispiel zeigt, wie man Hotkeys registrieren und 
  darauf reagieren kann, wenn sie gedrückt werden. (systemweit) 


unit Unit1; 

interface 

uses 
  Windows, Messages, Forms, Dialogs; 

type 
  TForm1 = class(TForm) 
    procedure FormCreate(Sender: TObject); 
    procedure FormDestroy(Sender: TObject); 
  private 
    // Hotkey Ids 
    id1, id2, id3, id4: Integer; 
    procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY; 
    { Privat-Declarations} 
  public 
    { Public-Declarations} 
  end; 

var 
  Form1: TForm1; 

implementation 

{$R *.DFM} 

// Trap Hotkey Messages 
procedure TForm1.WMHotKey(var Msg: TWMHotKey); 
begin 
  if Msg.HotKey = id1 then 
    ShowMessage('Ctrl + A was pressed !'); 
  if Msg.HotKey = id2 then 
    ShowMessage('Ctrl + Alt + R was pressed !'); 
  if Msg.HotKey = id3 then 
    ShowMessage('Win + F4 was pressed !'); 
  if Msg.HotKey = id4 then 
    ShowMessage('Print Screen was pressed !'); 
end; 


procedure TForm1.FormCreate(Sender: TObject); 
  // Different Constants from Windows.pas 
const 
  MOD_ALT = 1; 
  MOD_CONTROL = 2; 
  MOD_SHIFT = 4; 
  MOD_WIN = 8; 
  VK_A = 65; 
  VK_R = 82; 
  VK_F4 = 115; 
begin 
  // Register Hotkey Ctrl + A 
  id1 := GlobalAddAtom('Hotkey1'); 
  RegisterHotKey(Handle, id1, MOD_CONTROL, VK_A); 

  // Register Hotkey Ctrl + Alt + R 
  id2 := GlobalAddAtom('Hotkey2'); 
  RegisterHotKey(Handle, id2, MOD_CONTROL + MOD_Alt, VK_R); 

  // Register Hotkey Win + F4 
  id3 := GlobalAddAtom('Hotkey3'); 
  RegisterHotKey(Handle, id3, MOD_WIN, VK_F4); 

  // Globally trap the Windows system key "PrintScreen" 
  id4 := GlobalAddAtom('Hotkey4'); 
  RegisterHotKey(Handle, id4, 0, VK_SNAPSHOT); 
end; 

// Unregister the Hotkeys 
procedure TForm1.FormDestroy(Sender: TObject); 
begin 
  UnRegisterHotKey(Handle, id1); 
  UnRegisterHotKey(Handle, id2); 
  UnRegisterHotKey(Handle, id3); 
  UnRegisterHotKey(Handle, id4); 
end; 

end. 


  RegisterHotKey fails if the keystrokes specified for the hot key have 
  already been registered by another hot key. 
   
  Windows NT4 and Windows 2000/XP: The F12 key is reserved for use by the 
  debugger at all times, so it should not be registered as a hot key. Even 
  when you are not debugging an application, F12 is reserved in case a 
  kernel-mode debugger or a just-in-time debugger is resident. 
}


cu

Onz
JacFab
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 111



BeitragVerfasst: So 13.10.02 12:54 
Das ist wirklich ein interessantes beispiel!
leider hilft es mir bei meinem problem nicht weiter, denn ich will ja nur den status der einzelnen tasten rauskriegen!
ein konkretes beispiel:

ich würde gerne eine messagebox nur dann zeigen, wenn die strg(steuerungstaste) gedrückt ist.
Moritz M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: So 13.10.02 13:26 
Titel: Hi
Servus

Hab dir ein Beispiel ber Mail geschickt. Hoffe du kannst es dann umsetzen

cu

Onz
JacFab
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 111



BeitragVerfasst: So 13.10.02 15:33 
Ich habs bekommen.
Vielen Dank für deine mühe!!
Moritz M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: So 13.10.02 16:07 
Titel: Hi
Hi

Bitte! Gerne geschehen :P
Das haben andere in diesem Forum auch für mich getan...*snüff* :wink:

cu

Onz