AFX前綴的意義


微軟AFX

成立時間

1989年

成立公司

微軟公司

團隊

ApplicationFramework技術團隊,名爲AFX小組,用以開發C++對象導向工具給Windows應用程序開發人員使用。

AFX中的X

AFX 的"X"沒有什麼意義,是比較流行的結尾字符,如activex等。

當小組成員以此產品開發應用程序,他們發現實在是太複雜,又悖離公司的主流系統--Windows --太遙遠。於是他們修改憲章變成"deliver the power of object-oriented solutions to programmers to enable them to build world-class Windows based applications in C++." 這差不多正是Windows 3.0異軍崛起的時候。以afx開頭的函數不能說是MFC的全局函數,而是MFC的類函數。當初這個小組打算建立一個可以跨linux和windows平臺的設計軟件,結果失敗了,遺留了大量的函數以afx命名,最終用類的概念建立了MFC的框架,所以現在MFC之中有很多afx函數,這些函數可以用API函數替代。AFX 小組預期MFC 的使用者不可能人人皆爲C++ 專家,所以他們並沒有採用所有的C++高階性質(例如多重繼承)。許多「麻煩」但「幾乎一成不變」的Windows程序動作都被隱藏在MFC 類別之中, 例如WinMain、RegisterClass、Window Procedure 等等等。


MSDN中的解釋。 


MSDN中,關於AFX前綴的描述。只在MFC章節,《宏、全局函數、全局變量》一節。表示MFC裏面的全局函數和全局變量,大部分都是用了AFX前綴,只是沒有提到AFX工作組,也沒有提到AFX是什麼縮寫,實在是有點遺憾。還是網絡的資料提供比較全面,也算是一些野史吧。

Macros, Global Functions, and Global Variables

The topics in this section provide descriptions of the global functions, global variables, and macros in the MFC library.

Note   Many global functions start with the prefix "Afx" — but some, such as the dialog data exchange (DDX) functions and many of the database functions, deviate from this convention. All global variables start with the prefix "afx". Macros do not start with any particular prefix, but they are written all in uppercase.

The MFC library and the Active Template library (ATL) share string conversion macros. SeeString Conversion Macros in the ATL documentation for a discussion of these macros.

For information on the debug version of the C run-time library and diagnostic functions, seeDebug Routines, in the Run-Time Library Reference.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章