Really this is just to test if Restore DC works... Results are as if hMemDC to draw to does not exist because no line is drawn... Is RestoreDC correctly used in the above code?

04-11-2008

master5001

Ya know what, I was looking at the platform docs and its not so much that you are "doing it wrong" so much that it does something different than what you think it does.

Its supposed to retain information about the HDC not the HDC itself. Thus, what you are doing does what you told it to do (which was save information about drawing mode, pens used, etc.) however, you just thought it was going to store your HDC for later use (which it does not).

Don't be affraid to download the platform docs, btw. If you don't have high speed net just use http://msdn2.microsoft.com (which practically requires high speed due to server lag :( )

04-14-2008

csonx_p

Quote:

Originally Posted by master5001

what you are doing does what you told it to do (which was save information about drawing mode, pens used, etc.) however, you just thought it was going to store your HDC for later use (which it does not).

Oh! then how can i retain an original Bitmap DC? say i create a CompitableDC of a bitmap, draw a line on that bitmap, then delete DC (this done in a function).. By calling the function for the second time (or looping it) would like to continue drawing a different line but on an original Bitmap (one without a drawing)... My idea was to create a DC of the bitmap, save a copy as copiedDC, draw on draw something originalDC and delete. Next time i call the function i just need to restore the copiedDC with nothing drawn....

04-14-2008

master5001

Device contexts can be a screwy game. As you mess with them more and more you will swiftly realize their biggest draw back is creating them is a slow deal. So what I find useful is to do your CreateCompatibleDC() method but do all the drawing on the HDC of the window. The fewer HDCs you need to create (particularly in real-time) the better.