mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-25 03:55:02 +02:00
* fix fvisioncharmessage
This commit is contained in:
parent
6f8a05be13
commit
ff8468c792
@ -39,6 +39,10 @@ uses
|
|||||||
var
|
var
|
||||||
InputHandle : Handle;
|
InputHandle : Handle;
|
||||||
StoredControlKeyState : longint;
|
StoredControlKeyState : longint;
|
||||||
|
lastir : INPUT_RECORD;
|
||||||
|
|
||||||
|
const
|
||||||
|
LastChar : char = #0;
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -52,12 +56,12 @@ const
|
|||||||
{ 05 unassigned } #0,
|
{ 05 unassigned } #0,
|
||||||
{ 06 unassigned } #0,
|
{ 06 unassigned } #0,
|
||||||
{ 07 unassigned } #0,
|
{ 07 unassigned } #0,
|
||||||
{ 08 VK_BACK } #0,
|
{ 08 VK_BACK } #8,
|
||||||
{ 09 VK_TAB } #9,
|
{ 09 VK_TAB } #9,
|
||||||
{ 0A unassigned } #0,
|
{ 0A unassigned } #0,
|
||||||
{ 0B unassigned } #0,
|
{ 0B unassigned } #0,
|
||||||
{ 0C VK_CLEAR ?? } #0,
|
{ 0C VK_CLEAR ?? } #0,
|
||||||
{ 0D VK_RETURN } #0,
|
{ 0D VK_RETURN } #13,
|
||||||
{ 0E unassigned } #0,
|
{ 0E unassigned } #0,
|
||||||
{ 0F unassigned } #0,
|
{ 0F unassigned } #0,
|
||||||
{ 10 VK_SHIFT } #0,
|
{ 10 VK_SHIFT } #0,
|
||||||
@ -313,17 +317,35 @@ var
|
|||||||
begin
|
begin
|
||||||
fvisioncharmessagehandler:=0;
|
fvisioncharmessagehandler:=0;
|
||||||
if (AMessage = WM_CHAR) then
|
if (AMessage = WM_CHAR) then
|
||||||
exit;
|
begin
|
||||||
|
if LastChar<>#0 then
|
||||||
|
begin
|
||||||
|
Writeln('char ',chr(wparam and $ff),' $',hexstr(wparam,2));
|
||||||
|
Lastir.Event.KeyEvent.AsciiChar:=chr(wparam and $ff);
|
||||||
|
WriteConsoleInput(InputHandle,lastir,1,NumWritten);
|
||||||
|
LastChar:=#0;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Writeln('char ',chr(wparam and $ff),' $',hexstr(wparam,2),' ignored');
|
||||||
|
end;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
if LastChar<>#0 then
|
||||||
|
begin
|
||||||
|
WriteConsoleInput(InputHandle,lastir,1,NumWritten);
|
||||||
|
LastChar:=#0;
|
||||||
|
end;
|
||||||
fillchar(ir,sizeof(ir),#0);
|
fillchar(ir,sizeof(ir),#0);
|
||||||
ir.EventType:=KEY_EVENT;
|
ir.EventType:=KEY_EVENT;
|
||||||
with ir.Event.KeyEvent do
|
with ir.Event.KeyEvent do
|
||||||
begin
|
begin
|
||||||
vKey:=WParam and $ff;
|
vKey:=WParam and $ff;
|
||||||
|
wRepeatCount:=lparam and $ffff;
|
||||||
IsExtended:=(lParam and (1 shl 24))<>0;
|
IsExtended:=(lParam and (1 shl 24))<>0;
|
||||||
if AMessage = WM_KEYDOWN then
|
if AMessage = WM_KEYDOWN then
|
||||||
bKeyDown:=true;
|
bKeyDown:=true;
|
||||||
wVirtualKeyCode:=vKey;
|
wVirtualKeyCode:=vKey;
|
||||||
dwControlKeyState:=StoredControlKeyState;
|
|
||||||
AsciiChar:=KeyToAsciiCode[vKey];
|
AsciiChar:=KeyToAsciiCode[vKey];
|
||||||
if AsciiChar<>#0 then
|
if AsciiChar<>#0 then
|
||||||
begin
|
begin
|
||||||
@ -331,6 +353,8 @@ begin
|
|||||||
if ((StoredControlKeyState and SHIFT_PRESSED)=0) and
|
if ((StoredControlKeyState and SHIFT_PRESSED)=0) and
|
||||||
((wVirtualKeyCode>=VK_A) and (wVirtualKeyCode<=VK_Z)) then
|
((wVirtualKeyCode>=VK_A) and (wVirtualKeyCode<=VK_Z)) then
|
||||||
AsciiChar:=chr(ord(AsciiChar) + ord('a')-ord('A'));
|
AsciiChar:=chr(ord(AsciiChar) + ord('a')-ord('A'));
|
||||||
|
if bKeyDown then
|
||||||
|
LastChar:=AsciiChar;
|
||||||
end;
|
end;
|
||||||
case vKey of
|
case vKey of
|
||||||
VK_SHIFT :
|
VK_SHIFT :
|
||||||
@ -367,9 +391,12 @@ begin
|
|||||||
StoredControlKeyState:= StoredControlKeyState and not LEFT_ALT_PRESSED;
|
StoredControlKeyState:= StoredControlKeyState and not LEFT_ALT_PRESSED;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
dwControlKeyState:=StoredControlKeyState;
|
||||||
end;
|
end;
|
||||||
WriteConsoleInput(InputHandle,ir,1,NumWritten);
|
if Lastchar=#0 then
|
||||||
|
WriteConsoleInput(InputHandle,ir,1,NumWritten)
|
||||||
|
else
|
||||||
|
Lastir:=ir;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ this procedure allows to hook mouse messages }
|
{ this procedure allows to hook mouse messages }
|
||||||
@ -418,7 +445,10 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.1 2002-05-24 09:35:20 pierre
|
Revision 1.2 2002-05-28 19:12:26 pierre
|
||||||
|
* fix fvisioncharmessage
|
||||||
|
|
||||||
|
Revision 1.1 2002/05/24 09:35:20 pierre
|
||||||
first commit, not fully functional yet
|
first commit, not fully functional yet
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,10 @@ uses
|
|||||||
var
|
var
|
||||||
InputHandle : Handle;
|
InputHandle : Handle;
|
||||||
StoredControlKeyState : longint;
|
StoredControlKeyState : longint;
|
||||||
|
lastir : INPUT_RECORD;
|
||||||
|
|
||||||
|
const
|
||||||
|
LastChar : char = #0;
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -52,12 +56,12 @@ const
|
|||||||
{ 05 unassigned } #0,
|
{ 05 unassigned } #0,
|
||||||
{ 06 unassigned } #0,
|
{ 06 unassigned } #0,
|
||||||
{ 07 unassigned } #0,
|
{ 07 unassigned } #0,
|
||||||
{ 08 VK_BACK } #0,
|
{ 08 VK_BACK } #8,
|
||||||
{ 09 VK_TAB } #9,
|
{ 09 VK_TAB } #9,
|
||||||
{ 0A unassigned } #0,
|
{ 0A unassigned } #0,
|
||||||
{ 0B unassigned } #0,
|
{ 0B unassigned } #0,
|
||||||
{ 0C VK_CLEAR ?? } #0,
|
{ 0C VK_CLEAR ?? } #0,
|
||||||
{ 0D VK_RETURN } #0,
|
{ 0D VK_RETURN } #13,
|
||||||
{ 0E unassigned } #0,
|
{ 0E unassigned } #0,
|
||||||
{ 0F unassigned } #0,
|
{ 0F unassigned } #0,
|
||||||
{ 10 VK_SHIFT } #0,
|
{ 10 VK_SHIFT } #0,
|
||||||
@ -313,17 +317,35 @@ var
|
|||||||
begin
|
begin
|
||||||
fvisioncharmessagehandler:=0;
|
fvisioncharmessagehandler:=0;
|
||||||
if (AMessage = WM_CHAR) then
|
if (AMessage = WM_CHAR) then
|
||||||
exit;
|
begin
|
||||||
|
if LastChar<>#0 then
|
||||||
|
begin
|
||||||
|
Writeln('char ',chr(wparam and $ff),' $',hexstr(wparam,2));
|
||||||
|
Lastir.Event.KeyEvent.AsciiChar:=chr(wparam and $ff);
|
||||||
|
WriteConsoleInput(InputHandle,lastir,1,NumWritten);
|
||||||
|
LastChar:=#0;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Writeln('char ',chr(wparam and $ff),' $',hexstr(wparam,2),' ignored');
|
||||||
|
end;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
if LastChar<>#0 then
|
||||||
|
begin
|
||||||
|
WriteConsoleInput(InputHandle,lastir,1,NumWritten);
|
||||||
|
LastChar:=#0;
|
||||||
|
end;
|
||||||
fillchar(ir,sizeof(ir),#0);
|
fillchar(ir,sizeof(ir),#0);
|
||||||
ir.EventType:=KEY_EVENT;
|
ir.EventType:=KEY_EVENT;
|
||||||
with ir.Event.KeyEvent do
|
with ir.Event.KeyEvent do
|
||||||
begin
|
begin
|
||||||
vKey:=WParam and $ff;
|
vKey:=WParam and $ff;
|
||||||
|
wRepeatCount:=lparam and $ffff;
|
||||||
IsExtended:=(lParam and (1 shl 24))<>0;
|
IsExtended:=(lParam and (1 shl 24))<>0;
|
||||||
if AMessage = WM_KEYDOWN then
|
if AMessage = WM_KEYDOWN then
|
||||||
bKeyDown:=true;
|
bKeyDown:=true;
|
||||||
wVirtualKeyCode:=vKey;
|
wVirtualKeyCode:=vKey;
|
||||||
dwControlKeyState:=StoredControlKeyState;
|
|
||||||
AsciiChar:=KeyToAsciiCode[vKey];
|
AsciiChar:=KeyToAsciiCode[vKey];
|
||||||
if AsciiChar<>#0 then
|
if AsciiChar<>#0 then
|
||||||
begin
|
begin
|
||||||
@ -331,6 +353,8 @@ begin
|
|||||||
if ((StoredControlKeyState and SHIFT_PRESSED)=0) and
|
if ((StoredControlKeyState and SHIFT_PRESSED)=0) and
|
||||||
((wVirtualKeyCode>=VK_A) and (wVirtualKeyCode<=VK_Z)) then
|
((wVirtualKeyCode>=VK_A) and (wVirtualKeyCode<=VK_Z)) then
|
||||||
AsciiChar:=chr(ord(AsciiChar) + ord('a')-ord('A'));
|
AsciiChar:=chr(ord(AsciiChar) + ord('a')-ord('A'));
|
||||||
|
if bKeyDown then
|
||||||
|
LastChar:=AsciiChar;
|
||||||
end;
|
end;
|
||||||
case vKey of
|
case vKey of
|
||||||
VK_SHIFT :
|
VK_SHIFT :
|
||||||
@ -367,9 +391,12 @@ begin
|
|||||||
StoredControlKeyState:= StoredControlKeyState and not LEFT_ALT_PRESSED;
|
StoredControlKeyState:= StoredControlKeyState and not LEFT_ALT_PRESSED;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
dwControlKeyState:=StoredControlKeyState;
|
||||||
end;
|
end;
|
||||||
WriteConsoleInput(InputHandle,ir,1,NumWritten);
|
if Lastchar=#0 then
|
||||||
|
WriteConsoleInput(InputHandle,ir,1,NumWritten)
|
||||||
|
else
|
||||||
|
Lastir:=ir;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ this procedure allows to hook mouse messages }
|
{ this procedure allows to hook mouse messages }
|
||||||
@ -418,7 +445,10 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.1 2002-05-24 09:35:20 pierre
|
Revision 1.2 2002-05-28 19:12:26 pierre
|
||||||
|
* fix fvisioncharmessage
|
||||||
|
|
||||||
|
Revision 1.1 2002/05/24 09:35:20 pierre
|
||||||
first commit, not fully functional yet
|
first commit, not fully functional yet
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user