Jump to content
  • Advertisement


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


Need some mfc dc wrapper help (CClientDC,CPaintDC etc)

This topic is 5883 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

Ok ive got a problem to do with skinning a dialog with a bitmap and an activeX control. Ill Show you some code to make things clearer: My OnPaint() handler:
CPaintDC dc(this); // device context for painting

HDC hdc=dc.GetSafeHdc();
if(m_pSkin)//m_pSkin is my calss for skinning

	m_pSkin->Skin(&hdc);//CSkin::Skin(HDC*) just bitblits

                            //from its stored dc (with the bmp)

                            //to the hdc passed in

this works perfectly until i add a custom made activex control. The problem is that my activex control doesnt show up. I figured it was because the call to Skin() draws over the control (even though it doesnt paint over other controls like buttons and edit controls) so i did a bit of tinkering. I changed the CPaintDC to CClientDC and lo and behold it worked. I dont really understand the difference between CPaintDC and CClientDC (i know that CClientDC is the dc of the client area only but thats all)so I have no idea why this works but i was happy. That is until I put an OutputDebugString("Painting") in the OnPaint function. To my dismay it triggers over and over and over. I had no idea why, but if I change it back to CPaintDC it only triggers when its supposed to and the same if i remove the call to ::ReleaseDC() but if i remove that then i will get resource leaks right? Can anyone tell me why OnPaint is called over and over if i call ReleaseDC() with CClientDC and yet doesnt if i call ::ReleaseDC() with CPaintDC. And what is the difference between these 2 dc''s (also should i only be using CPaintDC in OnPaint()?) Finally does anyone have any idea on how to skin a window with an activex control on it and be able to show the activeX control without these problems? Sorry for all the questions but I feel I need to learn more about this area because i know very little about device contexts. Thanks for any help you can offer

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!