hi, i am using an mfc ListCtrl, is there anyway to know if a selection change was caused by mouse/keyboard input rather than a programatic change? i am after the same behaviour as ON_LBN_SELCHANGE for a listbox. thanks
views:
299answers:
2
A:
AFAIK there is no way to find out this information. You know if you are sending the message to the CListCtrl so you should set a flag if you do. If the LBN_SELCHANGE message is received and the flag has NOT been set then it must have come from a keyboard/mouse.
Goz
2010-01-29 08:51:09
Thank you for your help Goz.
Jon
2010-01-29 14:05:54
+1
A:
You can use GetKeyState() to find out whether a key or mouse button was pressed. Do not use GetAsyncKeyState() because that API will tell you the current state of the keyboard/mouse buttons, which may have changed when you handle the LBN_SELCHANGE message. GetKeyState() however will tell you the state as it was when LBN_SELCHANGE was generated.
Stefan
2010-01-29 17:08:31