如何通过Win32实现Slider控件 [英] How to implement a Slider control by win32

查看:120
本文介绍了如何通过Win32实现Slider控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:
在我的win32对话框应用程序中,有一个复选框和两个滑块控件.选中该复选框时,我想要的是将启用两个滑块控件.当拖动滑块控件时,它可以获取pos并显示int一个编辑控件.但是当我调试代码时,无法获取消息.

Hi all:
In my win32 dialog application,there is check box and two slider control.what i want is when checking the check box will enable the two slider control.when drag the slider control,it can get the pos and display int a edit control.But when i debug the code,it can''t get the message.

case WM_INITDIALOG:
	{
	   HWND sliderConLo = GetDlgItem(hwndDlg,IDC_SLIDERLOWER);
	   HWND sliderConHi = GetDlgItem(hwndDlg,IDC_SLIDERHIGHER);
	   SendMessage(sliderConLo,TBM_SETRANGE, (WPARAM)1,(LPARAM)MAKELONG(0,100));
           SendMessage(sliderConHi,TBM_SETRANGE, (WPARAM)1,(LPARAM)MAKELONG(0,100));
           SendMessage(sliderConLo,TBM_SETPOS, (WPARAM)1,0);
           SendMessage(sliderConHi,TBM_SETPOS, (WPARAM)1,0);
	}
	break;
case WM_HSCROLL:
        {
                 //how to implement it
        }


推荐答案

要在选中或取消选中复选框时执行操作,请使用发送到按钮父窗口的BN_CLICKED通知(您的对话框) ).根据复选框的状态,您可以启用或禁用滑块控件.

要处理滑块控件的鼠标拖动事件,请使用TB_THUMBTRACK通知.要同时处理键盘事件,请使用其他TB_*通知.
To perform actions when checking or unchecking a check box, use the BN_CLICKED notification send to the parent window of the button (your dialog). According to the state of the check box, you can than enable or disable the slider controls.

To handle mouse drag events for the slider controls, use the TB_THUMBTRACK notification. To handle also keyboard events, use the other TB_* notifications.


请参阅 ^ ],以获取有关由Trackbar控件生成的通知消息的信息.
See here[^] for information about the notification messages generated by a Trackbar control.


这篇关于如何通过Win32实现Slider控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆