| |
| BOOL TranslateMappedKey( |
| |
UINT nKey, |
|
| |
UINT nFlags, |
|
| |
UINT *lpnMappedKey, |
|
| |
LPTSTR lpszKeyBuffer, |
|
| |
UINT cchBuffer |
|
| ); |
| BOOL TranslateMappedKey( |
| |
UINT nKey, |
|
| |
UINT nFlags, |
|
| |
UINT *lpnMappedKey, |
|
| |
CString& strKeyBuffer |
|
| ); |
The TranslateMappedKey method translates a virtual key
press to an escape sequence based on the current terminal emulation
that has been selected.
Parameters
- nKey
- The virtual key code for the specified key.
- nFlags
- The scan code, key-transition code, previous key state, and
context code for the specified key.
- lpnMappedKey
- A pointer to an unsigned integer which will contain the index
into the keymap table when the method returns. This is the same
value used with the GetMappedKey and SetMappedKey
method. If the index into the keymap is not required, this
parameter can be NULL.
- lpszKeyBuffer
- Address of the buffer to receive the escape sequence mapped to
the specified key. If the mapped key string is not required, this
parameter can be NULL.
- cchBuffer
- The maximum number of characters that can be copied into the
key buffer, including the terminating null character. If the
lpszKeyBuffer parameter is NULL, this value must be
zero.
Return Value
If the virtual key can be mapped to an escape sequence, the method
will return a non-zero value. If the key is not mapped, or one of the
arguments is invalid, the method will return zero.
Remarks
The TranslateMappedKey method allows an application to map
a virtual key code to an escape sequence that is appropriate for the
type of terminal that is being emulated. For example, it will return
the escape sequence for the F1 method key when passed the VK_F1 key
value. This method should be called when the WM_KEYDOWN message is
processed by an application so that it may send the correct sequence
to the server.
This method should only be called in response to a keyboard
message such as WM_KEYDOWN. To determine if a specific key has been
mapped to an escape sequence, use the GetMappedKey method.
Example
case WM_KEYDOWN:
/*
* If the Num Lock key is pressed, then set the terminal into application
* keypad mode. This will change how the TranslateMappedKey method will
* translate the keypad keys.
*
* Note that the terminal may also be placed into application keypad mode
* if emulating a DEC VT terminal and the DECNKM escape sequence is sent
* by the host.
*/
if (wParam == VK_NUMLOCK)
pDisplay->SetMode(NVT_MODE_APPKEYPAD, !(GetKeyState(VK_NUMLOCK) & 1));
else
{
BOOL bMapped;
UINT nMappedKey;
TCHAR szKey[128];
bMapped = pDisplay->TranslateMappedKey(wParam, HIWORD(lParam),
&nMappedKey, szKey, 128);
if (bMapped)
pTelnet->Write(szKey);
}
break;
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csnvtv12.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
|
|