Sign in Join
FPDoc Onlineexperiment

KeysToShiftState function

In unit Forms

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

Declaration

pascal
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

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.