[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Forms' (#lcl)

# KeysToShiftState

Converts modifier keys in the LParam for a mouse message to a TShiftState value.

## Declaration

Source position: forms.pp line 1941

`function KeysToShiftState(`
`Keys: PtrUInt`
`):TShiftState;`

## Arguments

`Keys` |  | Pointer to an unsigned Integer with the mouse key states examined in the routine.

## Function result

Set type with the TShiftStateEnum values representing the specified Keys.

## Description

KeysToShiftState returns a TShiftState type with the TShiftStateEnum values needed to represent the mouse key states in the Keys argument. KeysToShiftState ANDs the value in Keys with RTL mouse key constants to determine the values in the set, including:

MK_Shift
  Includes ssShift for a non-zero result.
MK_Control
  Includes ssCtrl for a non-zero result.
MK_LButton
  Includes ssLeft for a non-zero result.
MK_RButton
  Includes ssRight for a non-zero result.
MK_MButton
  Includes ssMiddle for a non-zero result.
MK_XBUTTON1
  Includes ssExtra1 for a non-zero result.
MK_XBUTTON2
  Includes ssExtra2 for a non-zero result.
MK_DOUBLECLICK
  Includes ssDouble for a non-zero result.
MK_TRIPLECLICK
  Includes ssTriple for a non-zero result.
MK_QUADCLICK
  Includes ssQuad for a non-zero result.

GetKeyState is also called, and the following virtual key codes are processed for the return value:

VK_MENU
  Includes ssAlt when the result is a negative number.
VK_LWIN, VK_RWIN
  Includes ssMeta when the result is a negative number.

KeysToShiftState is used to translate the key values for mouse messages in methods like DoMouseDown, DoMouseUp, and WMMouseMove in TControl.

## See also

ShiftStateToKeys |  | Converts a shift state into a key state value compatible with the key state of a Windows API LParam.
KeyDataToShiftState |  | Converts modifier keys from the LParam in a keyboard message (WM_KEYUP for example) to a TShiftState value.
TShiftState
MK_SHIFT |  | A key state constant to represent the shift key, equivalent to ssShift from TShiftState.
MK_CONTROL |  | A key state constant to represent the control key, equivalent to ssCtrl from TShiftState.
MK_LBUTTON |  | A key state constant to represent the left mouse button, equivalent to ssLeft from TShiftState.
MK_RBUTTON |  | A key state constant to represent the right mouse button, equivalent to ssRight from TShiftState.
MK_MBUTTON |  | A key state constant to represent the middle mouse button, equivalent to ssMiddle from TShiftState.
MK_XBUTTON1 |  | A key state constant to represent the first extra mouse button, equivalent to ssExtra1 from TShiftState.
MK_XBUTTON2 |  | A key state constant to represent the second extra mouse button, equivalent to ssExtra2 from TShiftState.