Autor Beitrag
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Fr 23.02.07 23:08 
Hi,

brauche Tastatursteuerung für Form mit Labels. Am besten zuerst mal Anhang ansehen. Ziehe ich die Maus über die Labels, dann weren diese umrandet und farblich hervorgehoben.

Denselben Effekt möchte ich jetz erreichen mit den Pfeiltasten. Also rauf und runter. :mrgreen: Im Label fehlen aber die Keyboard-Events. Taborder kennt das aúch nicht. Was ist für einen solchen Zweck besser geeignet oder wie soll ich das machen ? :shock:
Einloggen, um Attachments anzusehen!
_________________
Gruß
Hansa
Dragonclaw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 196

Windows Vista
Delphi 7 Prof.
BeitragVerfasst: Fr 23.02.07 23:30 
Hallo,

du kannst einfach das FormKeyDown Event benutzen, das Ganze sieht dann etwa so aus.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key = vk_down then ShowMessage('Cursor Tastenach Unten');
if key = vk_up then ShowMessage('Cursor Tastenach Oben');
end;
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Fr 23.02.07 23:34 
user profile iconDragonclaw hat folgendes geschrieben:
Hallo,

du kannst einfach das FormKeyDown Event benutzen, das Ganze sieht dann etwa so aus.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key = vk_down then ShowMessage('Cursor Tastenach Unten');
if key = vk_up then ShowMessage('Cursor Tastenach Oben');
end;

Und sobald du noch eine zusätzliche Komponente, wie einen Button, auf der Form hast, funktioniert das ganze nicht mehr. Ist ja auch klar, dass dann die Keyboardbefehle an das fokusierte Objekt gehen - und dies ist nicht mehr form1! ;)
konbom
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 36

Win XP Home
Delphi 2005 Personal
BeitragVerfasst: Fr 23.02.07 23:48 
user profile iconMarc. hat folgendes geschrieben:

Und sobald du noch eine zusätzliche Komponente, wie einen Button, auf der Form hast, funktioniert das ganze nicht mehr. Ist ja auch klar, dass dann die Keyboardbefehle an das fokusierte Objekt gehen - und dies ist nicht mehr form1! ;)

ausblenden Delphi-Quelltext
1:
Form1.KeyPreview := true					

;)
MfG
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Sa 24.02.07 00:07 
Und ich sage dir, selbst dann funktioniert es nicht! ;)
konbom
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 36

Win XP Home
Delphi 2005 Personal
BeitragVerfasst: Sa 24.02.07 00:16 
Stimmt, du hast Recht. Habs grad mal ausprobiert und das geht nur bei OnKeyPress...
Da war ich nicht richtig informiert.
Sorry
lotus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

XP MediaCenter
Delphi 2005 Personal
BeitragVerfasst: Sa 24.02.07 01:10 
Ich glaube, die Komponente heißt TStaticText - ist wie ein Label, nur von TWinControl abgeleitet.

_________________
Das leben ist zu kostbar um es dem Schicksal zu überlassen! - Deus X Machina
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 24.02.07 10:08 
Auch ne Möglichkeit:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnMessage := AppMessage;
end;

procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean);
begin
  if Msg.message = WM_KEYDOWN then
  begin
    if (GetAsyncKeyState(VK_DOWN) and $8000 <> 0then
    begin
      ShowMessage('Nach unten');
      Handled := True;
    end;

    if (GetAsyncKeyState(VK_UP) and $8000 <> 0then
    begin
      ShowMessage('Nach oben');
      Handled := True;
    end;
  end;
end;

Dann kannste bei deinen normalen Labels bleiben.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
hansa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Sa 24.02.07 12:31 
Mühsam ernährt sich das Eichhörnchen. :mrgreen: GTA : WinApi & Co. sollten nur eingesetzt werden, wenn es gar nicht anders geht. Dasselbe gilt für "Application". Das muss anders gehen.

Das StaticText hat zumindest TabOrder und dann ? Bin vorerst bei TPanel gelandet. Das hat OnEnter, ich könnte also das Verhalten mit dem Rahmen usw. beibehalten.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure Tfrm.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if Sender is TPanel then
    if key = VK_DOWN then
      Perform(WM_NextDlgCtl, ord(Shift = [ssShift]), 0);
end;

procedure Tfrm.PanelEnter(Sender: TObject);
begin
  inherited;
  showmessage ((Sender as TPanel).Name);
end;


Mal sehen, wie weit ich komme. Wer noch andere Ideen hat : nur her damit.

_________________
Gruß
Hansa
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Sa 24.02.07 23:24 
Hallo,

andere Idee :gruebel:
nimm doch ein LabelGrid :mrgreen:

Hab Dir mal eine Demo erstellt
Einloggen, um Attachments anzusehen!
_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )