windows - MFC-- 遇到致命的死亡钻石

标签 windows visual-c++ mfc diamond-problem

Windows 编程新手。

我想创建一个同时使用 CPropertyPageCDHtmlDialog 的对话框吗?

class CPropertyPage : public CDialog  
class CDHtmlDialog  : public CDialog

由于我无法将上述每个案例的继承更改为“虚拟公共(public)”,是否仍然可以制作一个对话框,其中包含来自 CPropertyPage 的一些字段和来自 的一些表单>CDHtmlDialog?

最佳答案

您可以将 HTML 对话框创建为属性页的子对话框。唯一的问题是如果用户按下取消,子对话框将关闭。您必须覆盖 CDHtmlDialog::OnCancel。示例:

class CMyDHtmlDialog : public CDHtmlDialog
{
    void OnCancel()
    {
        //GetParent()->GetParent()->PostMessage(WM_COMMAND, IDCANCEL);
    }
};

class CMyPropertyPage : public CPropertyPage
{
    CMyDHtmlDialog child;
    BOOL OnInitDialog()
    {
        BOOL res = CPropertyPage::OnInitDialog();
        child.Create(IDD_HTML, this);
        CRect rc;
        GetClientRect(&rc);
        child.SetWindowPos(NULL, 0, 0, rc.Width(), rc.Height(), SWP_SHOWWINDOW);
        return res;
    }
};

关于windows - MFC-- 遇到致命的死亡钻石,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49456972/

相关文章:

java - 有效线程数

c++ - GetExtendedTcpTable 不会返回与 netstat -ano 相同的结果

c++ - 覆盖 OnFileOpen 和 OnFileSave 函数 - 注册表未更新?

python - Spyder3 Python IDE 无法启动 : "This Windows version does not support the required Bluetooth API"

c++ - 在 Windows 中检索已编译函数的大小

linux - 如何为 GIT 存储库中的文件创建符号链接(symbolic link)

visual-c++ - RC2135 文件未找到错误

c++ - 无法更改 VC++ CMFCOutlookBar 的 Tab 标签文本

visual-c++ - 在 Visual Studio 2013 中显示构建时间?

c++ - 如何创建自定义组件并将其添加到基于对话框的应用程序 (MFC)?