I have a TDrawGrid and want to handle clicking on a cell and scrolling through cells with the mouse wheel slightly differently: When scrolling with the mouse wheel, the view shall center on the selected cell, when simply clicking on a cell, the view shall not move (because that'd be confusing).
Scrolling with the mouse wheel fires the OnSelectCell
event. Clicking on a cell FIRST fires OnSelectCell
, followed by OnMouseDown
. So I need to figure out if OnSelectCell
was triggered by a mouse click. Easiest way to do (that I can think of) would be to check the current mouse-button state.
OnSelectCell
doesn't come with any TMouseButton
or TShiftState
parameter. So how can I query the mouse-button state?
Use GetKeyState
passing VK_LBUTTON
to identify the primary mouse button. If the return value is negative, the button was down when the system generated the input message that led to the OnSelectCell
event being fired.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With