天天看點

兩種方法檢視MFC源代碼

第一種--使用mfc.bsc源浏覽器檔案

    mfc.bsc是可以檢視mfc源代碼的檔案,其位置在mfc源代碼檔案夾下,visual studio版本不一樣的話,位置也不一樣。

vc6.0位置:c:/program files/microsoft visual studio/vc98/mfc/src/

vc2008sp1位置:d:/program files/microsoft visual studio 9.0/vc/atlmfc/src/mfc

類似的位置搜尋下就可以找得到,msdn上有三種方法添加.bsc檔案到工程,如下原文:

to open the .bsc file     * on the file menu, click open and open the .bsc file.       the .bsc file will be available to all projects in the solution until you either reload the solution or delete the .bsc file from solution explorer or the object browser. to attach the .bsc file to your project    1.in solution explorer, right-click the project node and click add existing item on the shortcut menu.    2.browse to the .bsc file and add it to your project.       the .bsc file will only be available in the project to which it is added. you can save the project so that the .bsc file will be available the next time that you open the project. you can delete the .bsc file from solution explorer to add the .bsc file to the object browser     *in the object browser, click the customize button and browse to the desired .bsc file.       when you add .bsc files to the object browser with the customize button, the files are available to all projects in any solution that you open. this setting will persist across visual studio sessions. the .bsc file that is referenced in each method will then appear in the object browser.

這裡介紹第三種方法,單擊“視圖”→“對象浏覽器”,在彈出的“對象浏覽器”面闆上“浏覽”→“編輯自定義元件集”→“浏覽”→“檔案類型”→“源浏覽器檔案(*.bsc)”,然後在mfc源代碼檔案夾下選擇mfc.bsc→“添加”→“确定”,步驟如下圖所示。

兩種方法檢視MFC源代碼
兩種方法檢視MFC源代碼

結果如下圖所示。

兩種方法檢視MFC源代碼
兩種方法檢視MFC源代碼

此時,假如我們要檢視某一個函數的話,在“搜尋”框輸入如:cdialog 回車,就會在左邊看到查詢到的類資訊,右邊是類成員函數和變量,在右邊可以按下想要搜尋的函數開頭字母,快速定位到以那字母開頭的函數,然後右鍵想要檢視的函數或變量選擇“轉到定義”,就會跳轉到源代碼處,如下圖所示。

兩種方法檢視MFC源代碼
兩種方法檢視MFC源代碼

彈出的源代碼定義,如下圖所示。

兩種方法檢視MFC源代碼
兩種方法檢視MFC源代碼

第二種--使用vax查找源代碼

    vax是visual studio插件,vc開發人員很多使用到它,它也可以檢視源代碼。在工具欄上左起第三個”find symbol“,如下圖所示。

兩種方法檢視MFC源代碼
兩種方法檢視MFC源代碼

在彈出的對話框,先勾掉”show only symbols defined in current solution",然後輸入要檢索的類或函數等等,如下圖所示。

兩種方法檢視MFC源代碼
兩種方法檢視MFC源代碼

結果也是定位到源代碼上,如下圖所示。

兩種方法檢視MFC源代碼