Re: How to modify the System Menu to execute a function
Mike, look at the code the framework generated for a standard VC++ 6.0 MFC dialog based application:
Code:
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
Do you see a difference between this code and yours?
Re: How to modify the System Menu to execute a function
Originally Posted by VictorN
Mike, look at the code the framework generated for a standard VC++ 6.0 MFC dialog based application:
Code:
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
Do you see a difference between this code and yours?
Victor, one thing that's always been cool about MFC is the source code is available. Don't know how to do something in your code?... just take a peak at the MFC source code and see how it's done there. What a fantastic learning tool.
Re: How to modify the System Menu to execute a function
Thank you for your kind help. I have it working now. Arjay, you are appropriate to point out that the answer was right in front of me, in the MFC source code. My problem was simply that my definitions for the items I wished to add were not in an accepable range. Once that was corrected everything worked out.
Re: How to modify the System Menu to execute a function
Originally Posted by Mike Pliam
Thank you for your kind help. I have it working now. Arjay, you are appropriate to point out that the answer was right in front of me, in the MFC source code.
Not trying to school here. When working on a new problem in MFC, I find it helpful to know that MFC if already does it, I usually try to track it down in the source to see how I can do it, or at least to give me a starting point. Sometimes, it's easy to miss some subtlety such as an out of range menu id like in this case.
Re: How to modify the System Menu to execute a function
One final question related to the System Menu of a Dialog app. Is it possible to remove the Move and Minimize items from the menu WITHOUT eliminating that functionality completely when user drags the title bar or clicks the minimize button?
Re: How to modify the System Menu to execute a function
I would recommend to leave those there as long as you're going to keep this standard functionality for your dialog, as you never know your end users' habits. You must have very good reasons to start modifying standard UI elements.
Re: How to modify the System Menu to execute a function
I agree. But I came across a little app that does exactly that and it seems to work just fine and the System Menu of the dialog is very clean and customized without minimize and move, yet the app minimize and move functionality is preserved, so there must be a way to do it. Anyway, you're right and I've just left it the way it is. Thanks for your thoughts, Igor.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.