Writing your own memory CDC code Occasionally students rebel at using the cMemoryDC class. ‘I…

Writing your own memory CDC code

Occasionally students rebel at using the cMemoryDC class. 'I want to use my own code; if I have to do this at our job, I want to be able to do it myself.' But do keep in mind that the MemoryDC. * files (and all the other software in this book) are welltested public domain freeware that you are explicitly authorized to reuse in any way, shape or form, with no acknowledgement necessary. But even so, there are individualistic souls who want to be sure they can do it unaided. And who can blame them? There is a sense, after all, in which you never completely understand code unless you have written it yourself, and then corrected your inevitable errors in the compiler, and then maybe even stepped through the code in the debugger. So this exercise asks you to write a screen-persistent version of Pop in which you don't use our cMemoryDC class. Here's how.

 Put a static CDC _memCDC variable into CPopView followed by a CBitmap _memBitmap and a couple of int _memcx, _memcy. We can live without the CBrush variable. Imitate the cMemoryDC constructor code inside the CPopView constructor. The initialization is the trickiest thing about a cMemoryDC, so this will be the hardest part of your work. Do it like this after using the GetSystemMetrics to set _memcx and _memcy to match the screen measurements.

Writing your own memory CDC code Occasionally students rebel at using the cMemoryDC class.

Copy this very exactly; resist the temptation to simplify things by leaving out the seemingly extra steps involving the temporary cDC_display variable. These steps are necessary. Now go to CPopView::OnDraw. Imitate the memory clear, using PatBlt with the WHITENESS as the last argument. And use BitBlt to imitate the copyTo code.

 You don't need to change the CPopView destructor, because the destructor will automatically call destructors on the CPopView data fields in the order they appear, which means _memDC.DeleteDC() will happen, and then _memBitmap.DeleteObject(). Of course if you'd created similar objects on a temporary basis somewhere, you might want to kill them off yourself, just to be sure that the CDC dies before the CBitmap (because if the CBitmap were to die first the CDC would have a cranky ant-fit!).

 And don't forget to override CView::OnEraseBkgnd(CDC *pDC) to do nothing at all but return TRUE;. If you forget this, your screen can still flicker, as the default behavior of any call to Invalidate() is to first call OnEraseBkgnd, and that function's default behavior is to erase the view with the background brush

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
The price is based on these factors:
Academic level
Number of pages
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
error: Content is protected !!