AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

abfragen, ob taste gedrückt ist

Ein Thema von dopeline · begonnen am 10. Jun 2003 · letzter Beitrag vom 12. Jun 2003
Antwort Antwort
Seite 1 von 2  1 2      
dopeline

Registriert seit: 7. Mär 2003
Ort: Berlin
304 Beiträge
 
Delphi 7 Enterprise
 
#1

abfragen, ob taste gedrückt ist

  Alt 10. Jun 2003, 16:06
Hallo!

Ich will abfragen, ob Überschreiben (Taste: Einfg) aktiviert ist. wenn ja, soll das in einem panel ausgegeben werden und wenn nicht, dann nicht...

hab mir gedacht ich mache es so:if (key = vk_Insert) then Statusbar1.Panels[1].text := 'Einfg'; das funktioniert aber nicht. außerdem fehlt noch die abfrage, insert ein- oder ausgeschaltet ist. wie stelle ich das an?

Grüße, dopeline
  Mit Zitat antworten Zitat
Benutzerbild von Jens Schumann
Jens Schumann

Registriert seit: 27. Apr 2003
Ort: Bad Honnef
1.644 Beiträge
 
Delphi 2009 Professional
 
#2
  Alt 11. Jun 2003, 14:16
Hallo,
hast Du die Formular-Property KeyPreview auf True gesetzt ?
  Mit Zitat antworten Zitat
CalganX

Registriert seit: 21. Jul 2002
Ort: Bonn
5.403 Beiträge
 
Turbo Delphi für Win32
 
#3
  Alt 11. Jun 2003, 14:20
Bessere Idee:
Form1.Keypreview auf true
Globale Variable: AbIns: boolean;
Im OnKeydown des Forms:
Delphi-Quellcode:
if (key = vk_Insert) then not AbsIns;
if AbsIns then StatusBar1.Panels[1].Text := 'Einfg'
else {...}
  Mit Zitat antworten Zitat
Benutzerbild von Jens Schumann
Jens Schumann

Registriert seit: 27. Apr 2003
Ort: Bad Honnef
1.644 Beiträge
 
Delphi 2009 Professional
 
#4
  Alt 11. Jun 2003, 18:28
Hallo,
seit wann fallen globale Variablen in die Kategorie "Bessere Idee" ?
  Mit Zitat antworten Zitat
CalganX

Registriert seit: 21. Jul 2002
Ort: Bonn
5.403 Beiträge
 
Turbo Delphi für Win32
 
#5
  Alt 11. Jun 2003, 18:31
In diesem Fall die einzige Möglichkeit...
Allerdings sollte man sich wohl doch das "Bessere Idee" weg denken. Eigentlich war es die Anleitung, wie er das machen soll.

Chris
  Mit Zitat antworten Zitat
Benutzerbild von Jens Schumann
Jens Schumann

Registriert seit: 27. Apr 2003
Ort: Bad Honnef
1.644 Beiträge
 
Delphi 2009 Professional
 
#6
  Alt 11. Jun 2003, 18:45
Hallo,
globale Variablen sind nie die einzige Lösung.
Eigentlch sind globale Variablen immer die schlechteste Lösung.
D.h. wenn man glaubt globale Vaiablen verwenden zu müssen, weiss sofort, dass das Programmdesign schwächen hat.
  Mit Zitat antworten Zitat
Benutzerbild von Duffy
Duffy

Registriert seit: 19. Mär 2003
Ort: Wuppertal
835 Beiträge
 
Delphi 3 Standard
 
#7
  Alt 11. Jun 2003, 18:55
Hallo dopeline,
als erstes solltest Du dir den Keyboard Status mit GetKeyboardState besorgen
Zitat:
The GetKeyboardState function copies the status of the 256 virtual keys to the specified buffer.

BOOL GetKeyboardState(

PBYTE lpKeyState // address of array to receive status data
);


Parameters

lpKeyState

Points to the 256-byte array that will receive the status data for each virtual key.



Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

An application can call this function to retrieve the current status of all the virtual keys. The status changes as a thread removes keyboard messages from its message queue. The status does not change as keyboard messages are posted to the message queue.
When the function returns, each member of the array pointed to by the lpKeyState parameter contains status data for a virtual key. If the high-order bit is 1, the key is down; otherwise, it is up. If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled.

To retrieve status information for an individual key, use the GetKeyState function.
An application can use the virtual-key code constants VK_SHIFT, VK_CONTROL and VK_MENU as indices into the array pointed to by lpKeyState. This gives the status of the SHIFT, CTRL, or ALT keys without distinguishing between left and right. An application can also use the following virtual-key code constants as indices to distinguish between the left and right instances of those keys:

VK_LSHIFT VK_RSHIFT
VK_LCONTROL VK_RCONTROL
VK_LMENU VK_RMENU


These left- and right-distinguishing constants are available to an application only through the GetKeyboardState, SetKeyboardState, GetAsyncKeyState, GetKeyState, and MapVirtualKey functions.
Dann kannst Du anzeigen was Du willst.
Künftige Generationen wollen ihre Fehler selber machen.
Jedes Programm wird nie das können, was Du wirklich brauchst.
Das Gegenteil von gut ist gut gemeint
-----
  Mit Zitat antworten Zitat
Hansa

Registriert seit: 9. Jun 2002
Ort: Saarland
7.554 Beiträge
 
Delphi 8 Professional
 
#8
  Alt 11. Jun 2003, 18:57
Jens hat da vollkommen Recht. Wer benutzt globale Variablen, außer in Ausnahmefällen? Je weniger, um so besser. In Basic gings nicht anders.
Gruß
Hansa
  Mit Zitat antworten Zitat
Benutzerbild von Nonsense
Nonsense

Registriert seit: 23. Nov 2002
389 Beiträge
 
Delphi 5 Standard
 
#9
  Alt 11. Jun 2003, 20:36
Das interessiert mich jetzt aber: Was spricht eigentlich gegen globale Variablen!?

  Mit Zitat antworten Zitat
CalganX

Registriert seit: 21. Jul 2002
Ort: Bonn
5.403 Beiträge
 
Turbo Delphi für Win32
 
#10
  Alt 11. Jun 2003, 20:47
Und mich würde es mal interessieren, wie man mit GetKeyboardState herausfinden soll, ob "Überschreiben" ein- oder ausgeschaltet ist...

Chris
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:36 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz