Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.11.25;
Скачать: CL | DM;

Вниз

keydown   Найти похожие ветки 

 
race1 ©   (2002-11-14 14:52) [0]

а как в {$APPTYPE CONSOLE} сделать перехват события, в частности, нажатия на клапку? компильятор - Delphi!


 
asmith   (2002-11-14 18:39) [1]

Грубо говоря, консольные аппликации не обрабатывабт событий в привычном смысле слова. Вот пример, как реагировать на нажатие клавиш и события от мыши, разберешься.

{$APPTYPE CONSOLE}
program ConsoleInput;

uses
Windows;

var
hInput: THandle;
arrInputRecs: array[0..9] of TInputRecord;
dwCur, dwCount: DWORD;
cCur: Char;
coorCur: TCoord;
begin
hInput := GetStdHandle(STD_INPUT_HANDLE);
while True do
begin
ReadConsoleInput(hInput, arrInputRecs[0], 10, dwCount);
for dwCur := 0 to dwCount - 1 do
case arrInputRecs[dwCur].EventType of
KEY_EVENT: with arrInputRecs[dwCur].Event.KeyEvent do
begin
cCur := AsciiChar;
if cCur = "" then
if bKeyDown then
WriteLn("Unprintable key pressed.")
else
Writeln("Unprintable key released.")
else
if bKeyDown then
WriteLn("Pressed ", cCur, " ", wRepeatCount, " times.")
else
WriteLn("Released ", cCur, " key.");
end;

{*** Delphi has renamed MOUSE_EVENT to avoid a conflict ***}
{*** with a windows function mouse_event() ***}
_MOUSE_EVENT: with arrInputRecs[dwCur].Event.MouseEvent do
begin
coorCur := dwMousePosition;
if dwEventFlags = 0 then
WriteLn("Button Pressed at ", coorCur.X, ",", coorCur.Y);
end;
end;
end;
end.



Страницы: 1 вся ветка

Текущий архив: 2002.11.25;
Скачать: CL | DM;

Наверх




Память: 0.46 MB
Время: 0.027 c
3-82661
StenKz
2002-11-06 15:47
2002.11.25
!!! Btrieve V7 for Dos как к нему обратиться?


1-82723
Maksss
2002-11-14 22:32
2002.11.25
Нужен исходняк JPEG.PAS из Delphi6 .


1-82801
AM
2002-11-13 11:10
2002.11.25
message loop


3-82637
AtoL
2002-11-05 12:10
2002.11.25
Можно ли узнать количество записей в TDBGrid?


3-82606
Fishka
2002-11-01 16:15
2002.11.25
Table(s) open. Cannot perform this operation. - Почему?