home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
NEWS
/
554
/
AVRIL
/
TV_F1112.TXT
< prev
next >
Wrap
Text File
|
1993-10-07
|
6KB
|
145 lines
─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 363 of 534
From : Michael Nicolai 2:2401/411.2 20 Apr 93 01:00
To : Christopher Turcksin 2:292/608.3
Subj : TurboVision F11/F12
────────────────────────────────────────────────────────────────────────────────
> Hello there!
>
> I noticed TurboVision doesn't support the F11 and F12 keys, since it uses
> the standard DOS/BIOS calls to read the keyboard which doesn't support those
Wrong! See INT 16h.
> keys either. However, Borland made it quite easy to implement this 'feature'
> in our TV apps. The only thing needed to do is override the
> TProgram.GetKeyEvent method in the app's TMyApplication (or whatever you
> derived from TApplication) object.
>
> However, I'm in trouble here since I don't have enough information on the
> extended keyboard services. So, if someone here would be so kind to supply
> me with the necessary information, I owe him a beer or two.
>
> Using the extended keyboard services has one disadvantage, but there's a
> workaround. It won't run on XT-type machines or AT's with an XT keyboard
> (are they still around?). The program can detect the presence of an extended
> keyboard, so if it's not available, it should call the original GetKeyEvent
> instead. Also, the commands mapped to the F11/F12 keys should also be
> available using an ALT-F1..10 combination (like in WP, ALT-F4 = F12) ...
>
> One additional advantage of using the extended keyboard is that you can
> detect if the key was pressed on the numerical keyboard. Although I think
> this is possible now too (the scancode is different for the + and the gray +)
>
> Christopher, TLA Crew Member
Since you only program on ATs, use this little function:
uses DOS;
function Get_Extended_KeyCode : word;
var
regs : Registers;
begin
regs.ah := $10;
intr($16, regs);
Get_Extended_KeyCode := (regs.ah shl 4) + regs.al;
end;
This function waits until a key is pressed.
The upper byte contains the scan code, the lower byte contains the ASCII
code.
If you don't want your program to hang if no key is pressed, use this
funtion to check if any keycode is actually present in the keyboard buffer:
uses DOS;
function Check_For_Extended_KeyStroke : boolean; { like KEYPRESSED }
var
regs : Registers;
begin
regs.ah := $11;
intr($16, regs);
Check_For_Extended_Keystroke := FALSE;
if ((regs.flags and fzero) = 0) then
Check_For_Extended_Keystroke := TRUE;
end;
After this function returns TRUE, the keycode can be read with
'Get_Extended_KeyCode'.
Here are the routines my functions are based on:
INTERRUPT 16h - Function 10h
Keyboard - Get enhanced keystroke
Purpose: Wait for any keyboard input.
Available on: AT or PS/2 with enhanced keyboard support only.
Restrictions: none.
Registers at call: AH = 10h.
Return Registers: AH = scan code, AL = ASCII code
Details: If no keystroke is available, this function waits until one is
placed in the keyboard buffer. Unlike function 00h, this function
does not discard extended keystrokes.
Conflicts: none known.
INTERRUPT 16h - Function 11h
Keyboard - Check for enhanced keystroke
Purpose: Checks for availability of any keyboard input.
Available on: AT or PS/2 with enhanced keyboard only.
Restrictions: none.
Registers at call: AH = 11h
Return Registers: ZF set if no keystroke available
ZF clear if keystroke available
AH = scan code
AL = ASCII code
Details: If a keystroke is available, it is not removed from the keyboard
buffer. Unlike function 01h, this function does not discard extended
keystrokes.
conflicts: none known.
INTERRUPT 16h - Function 12h
Keyboard - Get extended shift states
Purpose: Returns all shift-flags information from enhanced keyboards.
Available: AT or PS/2 with enhanced keyboard only.
Restrictions: none.
Registers at call: AH = 12h
Return Registers: AL = shift flags 1 (same as returned by function 02h):
bit 7: Insert active
6: CapsLock active
5: NumLock active
4: ScrollLock active
3: Alt key pressed (either Alt on 101/102-key
keyboard)
2: Crtl key pressed (either Ctrl on 101/102-key
keyboard)
1: left shift key pressed
0: right shift key pressed
AH = shift flags 2:
bit 7: SysRq key pressed
6: CapsLock pressed
5: NumLock pressed
4: ScrollLock pressed
3: right Alt key prssed
2: right Ctrl key pressed
1: left Alt key pressed
0: left Ctrl key pressed
Details: AL bit 3 is set only for left Alt key on many machines. AH bits 7
through 4 are always clear on a Compaq SLT/286.
Conflicts: none known.
So, i hope this will help you.
Oh, and since i drink no beer, a coke would be nice. :-)
Michael : [NICO] : [Whoo haz broquen mei brain-waschaer?]
~~~~~~~~~~~~~~~~