Why is the drop-down arrow for CMFCMenuButton not showing?

I ran into this problem when trying to add CMFCMenuButton to an existing MFC application. It worked correctly and even reduced the size of the button to place the down arrow. But he did not draw a down arrow, and when I hung over the button, I saw the following debug output:

> Can't load bitmap: 42b8.GetLastError() = 716
> CMenuImages. Can't load menu images 3f01

It turns out that even when using RTM Visual Studio 2010 when creating a new application based on MFC Dialog CMFCMenuButton does not draw an arrow and does not show the same errors. Initially, I assumed that I did not have anything installed or registered correctly. However, the NewControls example from the MFC function pack showed a drop-down arrow.

What is missing?

+4
source share
2 answers

The reason I posted this question is because I could not find the answers through Google. The closest I found when I explored this was a couple of hacks that didn't seem like a real solution. Scrolling through the NewControls example, I finally found the culprit.

At the bottom of the default .rc file for the project is the following code:

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#include "res\YOUR_PROJECT_NAME.rc2"  // non-Microsoft Visual C++ edited resources
#include "afxres.rc"      // Standard components
#endif

An example .rc of the NewControls file looks like this:

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#include "res\NewControls.rc2"  // non-Microsoft Visual C++ edited resources
#include "afxres.rc"      // Standard components
#ifndef _AFXDLL
#include "afxribbon.rc"      // Ribbon and control bars
#endif
#endif

afxribbon.rc , MFC. .rc. , , , . - YOUR_PROJECT_NAME.rc2:

#ifndef _AFXDLL
#include "afxribbon.rc"      // Ribbon and control bars
#endif

, , . , , afxribbon.rc, NewControls. .rc2, , .


, IDE RC:

  • RC " ...":

Right-Click RC File

  • :

Code Pasted into Window

+5

: CMyApp::InitInstance:

BOOL CMyApp::InitInstance()
{
    CWinAppEx::InitInstance();

    InitCommonControls();

    //This! 
    CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));

    //...
    return TRUE;
}
+1

Source: https://habr.com/ru/post/1752505/


All Articles