Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

tebriel

Windows device contexts

This topic is 5587 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Isn''t this a bad idea? (Passing screenDC like this--since it''s scope only lasts until the function ends...)
void CCaptureWindow::startCapture(void)
{
  HDC hdc = ::GetDC(NULL);
  CDC screenDC;
  screenDC.Attach(hdc);
  m_capManager = new m_capManager(&screenDC, m_xSource, m_ySource, m_width, m_height);
  ReleaseDC(&screenDC);
}
 
The m_capManager object stores screenDC as a CDC* which seems to me that it''d point to nothing after startCapture is finished, unless I just don''t understand device contexts or something.

Share this post


Link to post
Share on other sites
Advertisement
It looks to me that the call to ReleaseDC will invalidate the HDC stored in m_capManager. Do you really need to store that DC? Assuming you''re trying to do a screen capture - why not just store the captured image instead and use a new dc each time a capture is made?



"It is always a simple matter to drag the people along, whether it is a democracy, or a fascist dictatorship, or a parliament, or a communist dictatorship. Voice or no voice, the people can always be brought to the bidding of their leaders. That is easy. All you have to tell them is that they are being attacked and denounce the peacemakers for lack of patriotism and exposing the country to danger. It works the same in any country."
Hermann Goering

Share this post


Link to post
Share on other sites
I think that''s the case. The odd thing is that I think it was actually working with no obvious problems. I am going to create a new DC every time I need it afterall...I thought it would be easier not to but it probably doesn''t really matter!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!