Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C++
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
        }

Please help,thanks.
Posted
Updated 27-Feb-12 0:08am

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.
 
Share this answer
 
Comments
Member 8450542 27-Feb-12 6:49am    
i have try the below method,but failed.
case WM_HSCROLL:
{
switch(LOWORD(wParam))
{
case TB_THUMBTRACK:
{
LowerNum = HIWORD (wParam);
SendMessage(GetDlgItem(hwndDlg, IDC_LOWER), WM_SETTEXT, 0, LPARAM(pos));
}
}
}
break;
there is no actions as if the dialog have not get the message which the slider sents.
Jochen Arndt 27-Feb-12 7:14am    
You may add a TRACE command or set a breakpoint to see if the WM_HSCROLL message arrives.
Member 8450542 27-Feb-12 7:37am    
I set a breakpoint to debug the code and find that it can't even step to the line “case TB_THUMBTRACK”.I have no idea about it.
thanks a lot.can u help to write a demo about what i means.
Jochen Arndt 27-Feb-12 8:00am    
It is difficult to locate the problem without seeing your code. At least you should check the creation code of the sliders: The parent window handle must be those of your dialog and it must be created using the WS_CHILD and TBS_HORZ styles.
Member 8450542 1-Mar-12 7:18am    
Thanks,i have solved it.but i get another question. what's the difference between the follow codes.
case WM_HSCROLL :
dwPos = SendMessage(hWndSlider,TBM_GETPOS,0,0);
_itoa(dwPos,tmp,10);
SendMessage(hEdit,WM_SETTEXT,0,(LPARAM)tmp);
break;

case WM_HSCROLL :
dwPos = HIWORD(wParam);
_itoa(dwPos,tmp,10);
SendMessage(hEdit,WM_SETTEXT,0,(LPARAM)tmp);
break;
See here[^] for information about the notification messages generated by a Trackbar control.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900