簡體   English   中英

在VS2015 CLR上在CDialog派生類上創建返回0,在VC ++ 6中工作正常

[英]Create on a CDialog derived class returns 0 with VS2015 CLR, worked fine in VC++ 6

我正在嘗試遷移基於VC ++ 6的代碼以與VS2015 CLR一起使用。 我的主要功能正在運行,但是UI缺少一些東西。

由於父CWnd的NULL HWnd,我已將此問題追溯到SubclassDlgItem的失敗。 它為NULL,因為在dlgcore.cpp中,在CDialog派生的父類上創建時,在下面返回0。

if (hWnd != NULL && !(m_nFlags & WF_CONTINUEMODAL))
    {
        ::DestroyWindow(hWnd);
        hWnd = NULL;
    }

m_nFlags = 256(定義為#define WF_OLECTLCONTAINER 0x0100 //一些后代是afxwin.h中的OLE控件)

並且hWnd不是NULL,但是':: CreateDialogIndirect()不會創建窗口(即由於模板錯誤),並且根據Microsoft注釋會返回NULL'。

以下是父級CWnd的代碼

CreateEx(
            WS_EX_NOPARENTNOTIFY,
            NULL,
            "MainClient",
            WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
            0, 0,       // Locate at upper left corner of client area
            1, 1,       // Initial size doesn't matter - will be sized to fit parent
            parent->GetSafeHwnd(),
            NULL
        );

以下是CDialog創建的代碼

m_pMainDialog = new CxMainDialog();
m_pMainDialog->Create(IDD_MAIN_DIALOG, this);

下面是CxMainDialog構造函數

CxMainDialog::CxMainDialog(CWnd* pParent /*=NULL*/)
    : CDialog(CxMainDialog::IDD, pParent)
{

    //{{AFX_DATA_INIT(CxMainDialog)
        // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
}

我該如何工作?

解決方法是通過刪除創建時引起問題的ActiveX控件來修復對話框模板。 我創建了一個重復對話框並將其清空以測試創建是否成功。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM