How do I make the CTRL / SHIFT keys being pressed/released change the state (eg., color) of a TLabel under the mouse pointer without relying on the TLabel's mouse event handlers? (VCL, not FMX, in case it matters.)
CTRL/ALT/SHIFT generate KeyUp when used by themselves. I've see it. They don't generate a KeyDown by themselves apparently. Application.OnMessage should work for you as suggested by Attila Kovacs or if you want to go low level you can set a Windows Hook, however since you are looking for a TLabel, WindowFromPoint will not work as TLabel is not a windowed control (it will return the immediate windowed parent control containing the TLabel). You'll need to look at FindControlAtPos.
Do CTRL, ALT, and SHIFT (among others) generate key-down/up events? I seem to recall they're modifiers for regular keys.
ReplyDeleteCTRL/ALT/SHIFT generate KeyUp when used by themselves. I've see it. They don't generate a KeyDown by themselves apparently. Application.OnMessage should work for you as suggested by Attila Kovacs or if you want to go low level you can set a Windows Hook, however since you are looking for a TLabel, WindowFromPoint will not work as TLabel is not a windowed control (it will return the immediate windowed parent control containing the TLabel). You'll need to look at FindControlAtPos.
ReplyDelete