Sarath.

Hi All,

Recently I worked with a code which someone else has written.

The code is something as follows

BOOL MyDialog::OnInitDialog()
{
m_pDC = GetDC(); // m_pDC is the member of the dialog class
.....
}

void RenderBitmaps()
{
// Many drawing calls
m_pDC->SelectObject(bitmap);
m_pDC->StretchBlt(....);
}


In some other functions it is using m_pDC as the device context for draw. Normally at that time, we will call "GetDC()" and from the returning pointer will call the drawing functions. the person who written the code was trying to reduce the code hence make the code faster.

So can you see some hidden issue in the above said approach i.e making the DC Pointer as member

In the code execution, I dint find any issues :-D
What do you feel



Re: Visual C++ Language GetDC() call

Prasad Somwanshi

Actually it depend on what you are drawing using device context. But,I never seen device context as member variable.





Re: Visual C++ Language GetDC() call

Brian Kramer

Sarath, you are misusing this forum, as usual. Please reserve use of this forum for questions specific to the C++ language and compilation issues, not MFC or Win32 programming issues. If you need more help finding the right place, I'll be happy to give you some links.



Re: Visual C++ Language GetDC() call

Sarath.

Ohh ... Sorry Brian....

Sorry for posting it in wrong place. Thanks for pointing out the mistake.

Regards,
Sarat





Re: Visual C++ Language GetDC() call

Sarath.

One more thing, sometimes that pointer becomes invalid.. :-D