Autor Beitrag
FrEaKY
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 235


D7
BeitragVerfasst: Fr 19.03.04 22:46 
Hi
ich wollte so einen Shortcut machen wenn man zB Strg + O drückt. Aber es funktioniert noch nicht ganz.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (Key = vk_Control) then
   begin
    if (Key = vk_O) then
     begin
      if OpenDialog1.Execute then
     end;
   end;
end;


Kann mir jemand sagen was an 'if (Key = vk_O) then' falsch ist bzw wie es richtig geht? Danke schonmal
Gruß

Moderiert von user profile iconPeter Lustig: Code- durch Delphi-Tags ersetzt
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Fr 19.03.04 22:52 
Hi,

Du kannst nicht zweimal if Key = ... abfragen.
Der Parameter Key kann nur einen Wert annehmen.
Ob die Strg Taste gedrückt wird, sagt dir der Shift Parameter.


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (ssCtrl in Shift) and (Key = 79) then
    ShowMessage('Strg + O');
end;