BOOKS i'm reading |
Alternative to MFC for GDI programming
Contents
IntroductionI got the idea of developing this project after I started to study MFC GDI related classes. I saw a lot of code for features that I have never used. From there, I wanted to perform an experiment where I could verify if by using a stripped down version of GDI classes, it would translate to a better painting performance. As you will see in the conclusion, I did not obtain the results I was hoping for, and I hesitated to write a C++ Windows programming tutorial about the code I wrote. I concluded that if a fellow programmer was looking for an OO GDI encapsulation in a non MFC project, this code could be useful to him. In this C++ Windows programming tutorial, I will first describe what I did not like in MFC code, highlight the important points of the new class set, present the demo program, and conclude by presenting the result of the experiment.
MFC features for GDI classes not so useful
CPoint CDC::MoveTo(int x, int y) { ASSERT(m_hDC != NULL); CPoint point; if (m_hDC != m_hAttribDC) VERIFY(::MoveToEx(m_hDC, x, y, &point)); if (m_hAttribDC != NULL) VERIFY(::MoveToEx(m_hAttribDC, x, y, &point)); return point; } Also, related to
When it is And finally, the last source of overhead in MFC GDI classes is the handle maps. Handle maps are essential for window objects but I still have to see a situation with GDI objects where the handle maps are crucial. Handle maps are invoked when the functions
All these temporary objects will then be deleted the next time the MFC framework enters its idle function. |