Saving drawn objects

Started by
2 comments, last by Daubster 16 years, 11 months ago
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?
Where does he keep that gun?
Advertisement
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.
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.
Awesome, worked like a charm.
Thanks for the help. ^^
Where does he keep that gun?

This topic is closed to new replies.

Advertisement