Click here to Skip to main content
16,019,018 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Slider in mfc visual studio can have only 100 like maximum range or others value? Like 1500?
I wrote:

m_slider.SetRange(0, 1500);


but maximum range is always 100..

I know that maximum range is 100 because:
<pre>
void CDlgEntryPoint::OnNMCustomdrawSlider1(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
	// TODO: Add your control notification handler code here

	int value = m_slider.GetPos();

	*pResult = 0;
}





and value is 100 when I have maximum range

What I have tried:

I tried to use code that I wrote above
Posted
Updated 28-Mar-23 11:02am
v2
Comments
CHill60 28-Mar-23 10:15am    
How did you create m_slider and what happens when to try to use the code that you wrote - be specific
Member 14594285 28-Mar-23 10:17am    
I saw that range is always 100 and not 1500
Richard MacCutchan 28-Mar-23 10:43am    
You can set the range to anything you like.
Richard MacCutchan 28-Mar-23 12:26pm    
I have just tried the same with a non-MFC slider (which is the same underlying control) and it does what I expect. Your problem may have something to do with the fact that you are using a custom drawn control. But since we cannot see all your code that is a wild guess.
Shao Voon Wong 29-Mar-23 4:57am    
You can print and view the m_slider.GetPos() output in the debug window or DebugView.

char buf[250];
sprintf_s(buf, "m_slider.GetPos() : %d\n", m_slider.GetPos());
OutputDebugStringA(buf);

As has already been pointed out to you, the method of the CSliderCtrl class to call is SetRange. If I were you, I would approach this problem in two phases. First, use a standard slider control, not owner drawn, and make sure you can set its range and get its position and value correctly. You may want to use this old article I wrote, A smart edit and linked slider control[^] as a testbed to accomplish this. After you have that working, then I would change it to be owner drawn. The key thing here is to separate the functionality so that you can verify one thing is not affecting the other.
 
Share this answer
 
Comments
Member 14594285 29-Mar-23 5:26am    
I solved...in an other part of software was set to 0,100 so range didn't change
[no name] 30-Mar-23 4:51am    
tất cả chuyện đó đều bình thường,không có gì gọi là phhá hoại cả.
Rick York 30-Mar-23 18:10pm    
Great, I am glad to read that you succeeded.
Assuming you are using the MFC CSlider control, you can change the range: CSliderCtrl Class - SetRange method | Microsoft Learn[^]
 
Share this answer
 
Comments
Member 14594285 28-Mar-23 10:57am    
I use SetRange but I don't understand because range doesn't change, I put this function inside OnInitDialog
jeron1 28-Mar-23 11:14am    
Have you tried setting the third parameter in SetRange() to true?
Richard MacCutchan 28-Mar-23 11:31am    
How do you know it does not change?
Member 14594285 28-Mar-23 11:33am    
because I put a breakpoint when position is 100, and I saw that 100 is the maximum range
Richard MacCutchan 28-Mar-23 11:46am    
How did you see that 100 is the maximum range? As I stated above you can set the maximum range to any value up to 65535 as stated in the documentation.

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