0

I'm working on a legacy MFC project. The project includes an SDI application which has a menu-bar.

After launch, the menu-bar for the application is entirely greyed out:

enter image description here

I've read through the following questions, but they don't seem to address my situation:

MFC Menu Item remains grayed

Menu items are being enabled or disabled by default. Why?

Basically, the answers to the above question say that I need an ON_COMMAND handler, which exists for the menu functions I am interested in.

This is a very large proprietary project, so I can't simply post the code, and it could take a while to extract a minimum reproducible example. Is there any function name I can search for which might be disabling the menu-bar?

It looks to me like the entire menu bar is disabled, so I don't think my issue is related to individual ON_COMMAND handlers.

This didn't happen after some change, otherwise I would just roll back the change. I believe the application has been launching with a greyed-out menu bar since I began working on it.

The main application is a CWinApp-derived class, and the class where I added the ON_COMMAND handler is a CFrameWnd-derived class.

I'm developing in VS2019 (v142) using the Windows SDK version 10.0, and testing on Windows 10. I have a feeling (somewhat unsupported) that this particular issue is not closely related to the exact version of the compiler, or even Windows 10; my guess is that I am missing some detail of how MFC enables or disables menu-bars in general.

afarley
  • 781
  • 6
  • 26
  • What changed since last time the menu bar worked? If you "*can't simply post the code*" then you should at least try to narrow it down - what classes are used, version(s) of the compiler, version(s) of Windows etc. – dxiv Jan 28 '21 at 23:59
  • @dxiv I didn't make a change causing it to become greyed out; it's been this way since I began working on the application. I'll add details to the question re: compiler, etc. – afarley Jan 29 '21 at 00:00
  • I did not mean it was *your* change. But it would be quite odd if that menu bar never worked, so the question remains when was it that it last worked, and what changed since. – dxiv Jan 29 '21 at 00:18

1 Answers1

1

The "grayed out" means that the widget is disabled.

You'll need to EnableWindow on the widget. Specifying EnableWindow(FALSE) will disable the widget (window).

The tough part is to find out where or how this function is called. The state may be specified in a resource file. It may also be stated in an initialization method, or a constructor.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Thomas Matthews
  • 56,849
  • 17
  • 98
  • 154
  • Although this didn't directly answer the question, it led me to the solution because I started looking in places other than the class file. The issue in the end was that each menu-item in the resource had the Grayed property set to True. Simply setting it to false causes the menu headings to be enabled. – afarley Jan 29 '21 at 00:42
  • @afa If the answer didn't answer your question. don't accept it. Accepting an answer is a way of telling future visitors where to find an answer. This is not that place. – IInspectable Jan 29 '21 at 09:08
  • 1
    Wow, I thought you could accept the answer if it was *useful* and that answers didn't have to exactly answer the question. Many people provide answers as clues or suggestions (so as not to do the OP's work) and they still get accepted. – Thomas Matthews Jan 29 '21 at 19:36