In my never ending quest to better understand this language, just a simple question on which of the two snippets of code is "more appropriate" and why..
The class is derived from CSliderCtrl, just a customized UI widget and we're talking about OnPaint()
Otherwise I see no obvious difference. In the second example you you have one additional function call. Depending on the number of paint messages this could effect execution speed (but I doubt that you will recognize).
The only reason to use method 2 I could see is when you need to draw outside the client area. But since it will be clipped to the client area in OnPaint you won't see any effect. You need to override OnNcPaint to draw in the non client area.
0
PMH4514Author Commented:
I like your first comment, even less code.. I didn't realize BeginPaint and EndPaint were called by the constructor/destructor of dc.
Not of every DC. This is only true for a CPaintDC but for example not for a CWindowDC. Latter only calls GetDC on construction and ReleaseDC on destruction but will not reset the invalid area which BeginPaint does. So keep in mind that only a CPaintDC is calling BeginPaint and EndPaint !!!!!!
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
void CProgressSlider::OnPaint()
{
CPaintDC dc(this); // BeginPaint is called in constructor of dc
DrawProgress(&dc);
} // EndPaint is called in destructor of dc