{"id":4698,"date":"2014-03-30T14:45:43","date_gmt":"2014-03-30T14:45:43","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/cmfcribbonbar-inside-a-cdialogex-collection-of-common-programming-errors\/"},"modified":"2014-03-30T14:45:43","modified_gmt":"2014-03-30T14:45:43","slug":"cmfcribbonbar-inside-a-cdialogex-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/cmfcribbonbar-inside-a-cdialogex-collection-of-common-programming-errors\/","title":{"rendered":"CMFCRibbonBar inside a CDialogEx-Collection of common programming errors"},"content":{"rendered":"<p>In my CDialogEx class, I am trying to insert a CMFCRibbonBar, but I get a NULL pointer exception (which is not caught by my try\/catch blocks):<\/p>\n<pre><code>BOOL CmfcRibbonTestDlg::OnInitDialog()\n{\n    CDialogEx::OnInitDialog();\n\n    \/\/ Set the icon for this dialog.  The framework does this automatically\n    \/\/  when the application's main window is not a dialog\n    SetIcon(m_hIcon, TRUE);         \/\/ Set big icon\n    SetIcon(m_hIcon, FALSE);        \/\/ Set small icon\n\n    \/\/ TODO: Add extra initialization here\n    try\n    {\n        m_wndRibbonBar.Create(this);\n        m_wndRibbonBar.LoadFromResource(IDR_RIBBON1);\n    }\n    catch( std::exception&amp; exc )\n    {\n        this-&gt;MessageBoxA(exc.what(), \"Couldn't create ribbon\");\n    }\n\n    return TRUE;  \/\/ return TRUE  unless you set the focus to a control\n}\n<\/code><\/pre>\n<p>The exact exception says: &#8220;Unhandled exception at 0x00d191db in mfcRibbonTest.exe: 0xC0000005: Access violation reading location 0x00000000&#8221; and breaks in afxribbonbar.cpp:964.<\/p>\n<p>I did a number of searches to see if a CMFCRibbonBar can be placed in a dialog, but my searches were inconclusive.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my CDialogEx class, I am trying to insert a CMFCRibbonBar, but I get a NULL pointer exception (which is not caught by my try\/catch blocks): BOOL CmfcRibbonTestDlg::OnInitDialog() { CDialogEx::OnInitDialog(); \/\/ Set the icon for this dialog. The framework does this automatically \/\/ when the application&#8217;s main window is not a dialog SetIcon(m_hIcon, TRUE); \/\/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4698","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4698","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4698"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4698\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4698"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4698"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4698"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}