Click here to Skip to main content
15,882,113 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I wrote a similar example of sliding control, the results of each slide the slider, there appeared the following chart, from Figure 1, after sliding to the left block in Figure 2.
Figure I

Figure 2

Chart below is the main code block:
void SliderBoth::SetBlockColor()
CClientDC dc(this);
CRect rc;
GetClientRect(&rc);
int iNumTic=(pos.iMax-pos.iMin)/pos.iTick;
const int iL=MARGIN_SLIDE;
const int iR=rc.right-MARGIN_SLIDE;
const double dbStep=(iR-iL)*1.0/iNumTic;
double db=iL;
CBrush brush;   
brush.CreateSolidBrush(RGB(165,196,211));   
CBrush * pOldBrush= dc.SelectObject (&brush);

dc.Rectangle((int)lval+MARGIN_SLIDE*2,rc.top+1,(int)rval,rc.bottom-MARGIN_SLIDE*2);  
dc.SelectObject (pOldBrush);
brush.DeleteObject();
#endif
}


How can we solve this problem, obtain the DC I have problems?
Please help, thank you!
Posted
Updated 28-Jun-11 22:24pm
v2
Comments
Richard MacCutchan 29-Jun-11 4:27am    
I have deleted the erroneous 'solution' entries you posted. As you can see (by looking at your question) the figures do not appear here. You will have to upload them elsewhere and post a link, or explain your problem better. If you need to add more information please edit your question, do not add information as solution entries.

1 solution

in the SetBlockColor() function you should only change the color and than post a WM_PAINT message to the control.

In the overriden OnPaint() you should do the drawing.
 
Share this answer
 
Comments
Alain Rist 4-Jul-11 11:28am    
Never send or post a WM_PAINT message, use Invalidate().

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