如果MFC真得很强,SDK应当是很容易的,不过习惯了MS的AppWizard的人,再去手工写Win32 C,恐怕不是那么舒服的,有句话怎么说来的:"由简入奢易,由奢入简难"。但从原理上是一样的:消息机制。没有SDK的基础学MFC不太容易学好,这一点好像Charles Petzold也是这么看的:
MFC is particularly problematic. While it simplifies some jobs immensely (such as OLE), I often find myself wrestling with other features (such as the Document/View architecture) to get them to work as I want. MFC has not been the Windows programming panacea that many hoped for, and few people would characterize it as a model of good object-oriented design. MFC programmers benefit greatly from understanding what's going on in class definitions they use, and find themselves frequently consulting MFC source code. Understanding that source code is one of the benefits of learning the Windows API.
(特别是MFC问题多多。尽管在MFC中一些工作可以简化,如OLE,但为了使程序正常工作不得不费尽心思弄懂诸如想文档/视等其他的特征。MFC并非如一些人所希望的那样,是编程的万能药,而且几乎没有人把它当作是设计良好的OO模型。MFC程序员如果要理解了所使用类的内部机制,就得要经常参考MFC的原码,而能理解这些原码正是学习Windows API的好处之一)。
CP的意思是说,要真正理解MFC,首先得理解Win32 API。
OPENFILENAME m_openfile;
m_openfile.nFilterIndex=m_iFilterIndex;
m_openfile.lpstrFile=m_szFileName;
BOOL m_bReturn=GetOpenFileName(&m_openfile);
其中:TCHAR m_szFileName[1024];
TCHAR m_szCustomFilter[256];
如果是在函数里声明则不能显示对话框,声明为全局则可以了,局部时错误信息为:CDERR_INITIALIZATION The common dialog box function failed during initialization. This error often occurs when sufficient memory is not available 什么道理呢?是在堆上分的内存吧,太大了?