HOWTO 給 ATL 專案新增 MFC 支援

2021-04-13 09:26:35 字數 2582 閱讀 8562

文章編號

:173974

最後修改

:2023年1月21日修訂:

2.0

本文的發布號曾為 chs173974

本頁概要

更多資訊

給 atl exe 專案新增 mfc 支援

將 mfc 支援新增到 atl dll 專案

參考

回到頂端

1.在包括 atlbase.h 之前,將以下 #include 指令新增到 stdafx.h:

#include // mfc core and standard components

#include // mfc extensions

#include // mfc automation extensions

2.更改專案設定以使用 mfc。 在project settings對話方塊中,單擊general選項卡,然後將microsoft foundation classes列表框中的設定更改為 mfc。

3. ;

4. // initialize ccommodule.

_module.init(objectmap, m_hinstance);

_module.dwthreadid = getcurrentthreadid();

// check command line arguments.

tchar sztokens = _t("-/");

m_brun = true;

lpctstr lpsztoken = findoneof(m_lpcmdline, sztokens);

while (lpsztoken != null)

// unregister servers.

// there is no unregistration code for mfc

// servers. refer to q186212 "howto: unregister mfc

// automation servers" for adding unregistration

// code.

else if (lstrcmpi(lpsztoken, _t("unregserver"))==0)

// register atl and mfc objects in the registry.

else if (lstrcmpi(lpsztoken, _t("regserver"))==0)

lpsztoken = findoneof(lpsztoken, sztokens);

} if (m_brun)

return true;

} _module.term();

return 0;}5.

對於 unicode 版本,請確保進入點被設定為 wwinmaincrtstartup,該設定在project settings對話方塊中link欄位的output類別中。 有關其它資訊,請參見 microsoft knowledge base 中的下列文章:

125750

(http://support.microsoft.com/kb/125750/en-us/) prb: 錯誤 lnk2001: 「_winmain@16」: 不能解析的外部符號

6.有關 afx_manage_state 的詳細資訊,請查詢 vc++ 聯機文件。

181505

回到頂端

執行上面的步驟 1 到步驟 3。

1.{ // mfc's class factories registration is

// automatically revoked by mfc itself.

if (m_brun)

_module.revokeclassobjects();

2.將以下**行新增到 com 介面、視窗過程和匯出函式的每個成員函式的開頭:

afx_manage_state(afxgetstaticmodulestate());
有關其它資訊,請參見 microsoft knowledge base 中的下列文章:

140850

(http://support.microsoft.com/kb/140850/en-us/) howto: 轉換 dlltrace 以使用共享庫中的 mfc

備註:對於所有的發行版本,請確保 _atl_min_crt 預處理器定義已經被刪除。 您可以在project settings對話方塊中c/c++選項卡的preprocessor類別中找到這些定義。

當使用 classwizard 將乙個從 mfc 類衍生的類新增到 atl exe 專案或 atl dll 專案時,如果沒有「mfc 支援」,編譯器將發出 c2504 錯誤訊息。

回到頂端

mfcatl 示例附帶在 visual c++ 5.0 中。 

給專案新增MySQL使用者

1 建立資料庫表 create database 表名 charset utf8 2 建立普通使用者 create user 使用者名稱 identified by 使用者密碼 建立使用者賬號 meiduo,密碼 meiduo 由identified by 指明 3 給使用者新增許可權 grant ...

如何給專案新增富文字

在新增之前,我們要知道前台form和普通不上傳的form的區別。form表單提交,要使用流的技術通訊。普通的form表單是以字元流的形式提交,提交的方式有post和get。而前台form表單是以位元組流的形式通過post提交的。預設的編碼 enctype multipart form data me...

給已有的專案新增govendor

go get u v github.com kardianos govendorcd 到專案目錄下 執行 govendor init govendor add external參考大佬文章 更新引用的本地專案 update 如user manage專案裡面引用了order manage專案。當ord...