CSliderCtl and Arrow Keys?
-
Is there an easy way to have the CSliderCtl behave the same way when you use the arrow keys as it does when you click/drag it with the mouse? It moves the slider up and down, but how do I trap the message, the CSliderCtl only sends NM_OUTOFMEMORY, NM_RELEASEDCAPTURE, and NM_CUSTOMDRAW. I want the arrow keys to perform the same tasks I do when I handle the M_RELEASEDCAPTURE message. Ken Goguen
-
Is there an easy way to have the CSliderCtl behave the same way when you use the arrow keys as it does when you click/drag it with the mouse? It moves the slider up and down, but how do I trap the message, the CSliderCtl only sends NM_OUTOFMEMORY, NM_RELEASEDCAPTURE, and NM_CUSTOMDRAW. I want the arrow keys to perform the same tasks I do when I handle the M_RELEASEDCAPTURE message. Ken Goguen
I haven't tried this myself, but I think it should work:
- Derive
CMySliderCtrl
fromCSliderCtrl
. - add a member variable
int m_pos
and handlers forWM_KEYDOWN
andWM_KEYUP
. - in
OnKeyDown
, store the current position inm_pos
. InOnKeyUp
, compare the position with the one you stored. If they're different, issue the appropriateNM_RELEASEDCAPTURE
withWM_NOTIFY
. Check for repeat counts (holding the key pressed) inOnKeyDown
for improved results.
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
- Derive
-
I haven't tried this myself, but I think it should work:
- Derive
CMySliderCtrl
fromCSliderCtrl
. - add a member variable
int m_pos
and handlers forWM_KEYDOWN
andWM_KEYUP
. - in
OnKeyDown
, store the current position inm_pos
. InOnKeyUp
, compare the position with the one you stored. If they're different, issue the appropriateNM_RELEASEDCAPTURE
withWM_NOTIFY
. Check for repeat counts (holding the key pressed) inOnKeyDown
for improved results.
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
Seems to work well. Thanks, -kg Ken Goguen
- Derive