From: Arny on

On 13.04.2010 19:26, John Smith wrote:
> "ScottMcP [MVP]"<scottmcp(a)> wrote:
>> On Apr 12, 3:47 am, John Smith<do_not_...(a)> wrote:
>>> What about a situation like this
>>> hdc=GetDC(mywindow)
>>> oldhdc=SelectObject(hdc,GetStockObject(somestockobject));
>>> ..blah blah couple of lines of code for example
>>> ReleaseDC(hwnd,hdc);
>>> Do I have to select back the oldhdc before releasing the hdc?
>> Yes. Always. As stated in the SelectObject function description.
> I would think that no memory is lost if in above example. Am I correct?

Correct. Stock objects are maintained by the system. Calling
DeleteObject() is unnecessary for stock objects, but it will not do any
harm (ref. SDK).

- RaZ