简体   繁体   English

使ON_NOTIFY_RANGE与CSliderCtrl一起使用

[英]Getting ON_NOTIFY_RANGE to work with CSliderCtrl

I have an array of CSliderCtrl's in my windows form that I need to receive notifications from. 我的Windows窗体中有一个CSliderCtrl数组,我需要从中接收通知。 I am using the ON_NOTIFY_RANGE declaration to map the slider updates to the appropriate handler. 我正在使用ON_NOTIFY_RANGE声明将滑块更新映射到适当的处理程序。 My problem is that the only event that gives me a notification is the NM_RELEASEDCAPTURE event. 我的问题是,给我通知的唯一事件是NM_RELEASEDCAPTURE事件。 So my code looks like this: 所以我的代码看起来像这样:

BEGIN_MESSAGE_MAP(CTheThingDlg, CDialogEx)
   ON_NOTIFY_RANGE(NM_RELEASEDCAPTURE, start_id, end_id, handler)
END_MESSAGE_MAP()

void MyClass::handler(UINT p_id, NMHDR* p_notify_msg_ptr, LRESULT* p_result_ptr)
{
   //Do Stuff
}

I have tried using the WM_H/VSCROLL, TB_THUMBTRACK, TB_LINEUP/DOWN, and other events, but none give me the notification whether I use the mouse or keyboard to scroll. 我已经尝试过使用WM_H / VSCROLL,TB_THUMBTRACK,TB_LINEUP / DOWN和其他事件,但是没有人通知我是否使用鼠标或键盘滚动。 They are just simple horizontal scroll bars created with the following code: 它们只是使用以下代码创建的简单水平滚动条:

slider_ctrl.Create(WS_CHILD | WS_VISIBLE | TBS_HORZ | TBS_BOTTOM | TBS_FIXEDLENGTH,
                   CRect(x1, y1, x2, y2),
                   this,
                   id);

A penny for your thoughts. 一分钱的想法。

You need to handle the WM_HSCROLL message. 您需要处理WM_HSCROLL消息。 TB_THUMBTRACK and the other TB notifications are not messages, they are passed to the WM_HSCROLL message handler in the nSBCode parameter. TB_THUMBTRACK和其他TB通知不是消息,它们在nSBCode参数中传递给WM_HSCROLL消息处理程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM