Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.016 c
1-82744
alex_ran
2002-11-15 11:29
2002.11.25
Странное поведение Visible


14-82971
nick_vstu
2002-11-05 10:32
2002.11.25
Вам нравится група Ленинград?


6-82886
keymaster
2002-09-25 16:44
2002.11.25
Трафик по диалапу


3-82682
pavelsinicinV
2002-11-07 19:22
2002.11.25
Физический номер записи


1-82746
Sectey
2002-11-15 11:20
2002.11.25
Организация MDI проектов или меню, толбары в MDI приложениях.




   Наверх