How to keep CDC* pDC around for life of application?
Posted on 1998-09-24
Currently, I use MFC (SDI application), and I need to refer to CDC* pDC for drawing at many places, however, these are not called from within OnDraw() or OnPaint() (basically I can not pass in CDC), every time I need the DC, I use GetDC() to get a pointer to it. Unfortunally, these calls happen quite a lot, I end up call GetDC() too many time, and this is not efficient, and everytime I call GetDC() it seems to erase what I draw before. My question is:
Is there a way to get DC once and refer to it when needed? It look like the pointer returns from GetDC() is just a temporary pointer, it becomes NULL as soon as I get out of function scope. Thanks,