Sign in to follow this  

Saving drawn objects

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

Hey, I've been trying to make a very simple tic-tac-toe interface in an MFC dialog recently.. I'm drawing the shapes with a CClientDC object. No problems with that. Though minimizing/resizing the window makes all the shapes disappear. Now I know, that you need to draw on a bitmap to fix this, though I have no idea how to do that. Any help?

Share this post


Link to post
Share on other sites
Drawing the shapes to a bitmap isn't neccesarily the only solution.

I don't know anything about MFC, but in normal Win32 stuff, you'd just need to store enough information to redraw the shapes (i.e. position and so on) and redraw them whenever you get a WM_PAINT message. That will solve the minimizing and maximizing issue. I'd suspect you lose your images if you drag another window over your window then away again.

I assume MFC provides a virtual function or something you can use to respond to WM_PAINT under the hood.

Share this post


Link to post
Share on other sites
Quote:
Original post by EasilyConfusedI assume MFC provides a virtual function or something you can use to respond to WM_PAINT under the hood.

Yep; just override OnPaint() in your CDialog-derived class, and create a CPaintDC in that method to do your drawing. Then all your drawing code will be run every time the window is invalidated.

Share this post


Link to post
Share on other sites

This topic is 3873 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this