Recently, I am writing something about MFC because I have made some MFC projects and some scattered things need to be summarized. But this does not mean that I like him, but it is quite annoying. After all, I read the. NET Framework, and then I looked at the MFC N years ago. I don't dare to say much about the mechanism. Some Variables and method names have been set from the FCL design perspective, and I feel a little uncomfortable. Maybe I am too weak, maybe because I still don't have enough experience in designing it, listing some entertainment.
1. When constructing a custom dialog object, we will pass in a cwnd pointer, the object named pparent. However, when I call the getparent function in dialog, No matter what pointer (such as cyourview) is passed in, the returned value is a pointer to cmainframe. I have been calling this for N years.ProgramI admit that this is because I do not know enough about MFC, but the name is too confusing.
2. Of course, there is also the notorious updatedata function. It is a great honor for me and the master to take a look at the significance of the strange bool variable every time I use it. Maybe this is not a problem when I have IDE, but it is very troublesome when I read books. Separating them into two clearly-named functions may be much better.
3. showwindow. That's it. People who are not familiar with MFC should think that this name is used to display a window. But... in fact, it has both the function of displaying and hiding the window, and it is a strange bool volume...
4. movewindow and setwindowpos. This one is not focused enough. They are so powerful that they can do much more than just move and setpos. When I want to change the size of a form, I have never imagined how to find a function, it turned out to be the work of this unsung brother, faint...
5. getwindowrect and getclientrect. In fact, they may have no problem. The problem is that I don't like to use the reference instead of something that seems to be completed by the return value...
6. SelectObject. Why do you pass in a new object and it returns an old object? I am not the only one, but many people are confused by this. In fact, I don't understand that a function is too enthusiastic to do two functions...
7. afx_msg. A reserved amount never used. There are many such items in MFC...