John500
asked on
How To Insert An Executeable In An MFC Application Menu Item
Greetings,
I want to insert an executable in my application as a submenu item from the main menu bar. What code is necessary to do this?
This is what I know so far:
In the 'Docked Window' under the 'Rescource' tab and the subfolder marked 'Menu' are two IDR objects. One is the default IDR_MAINFRAME, the other is the IDR_PROJECTNAME.
If the project IDR is selected, the current available menu items are displayed in the workspace. From here on, I need help. What steps make it possible to launch an exe from the menu item I select?
I'm guessing that I should select the menu item in which the exe should appear as a submenu item. Then, from that dropdown list, select the blank box listed as the last submenu item, choose properties, select an 'ID:' from the dropdown box, type in a caption in the Caption Box. Even if I'm correct in these steps, I'm sure some code needs to be inserted somewhere.
This is where I need help, can you help me with these steps?
Thanks!
I want to insert an executable in my application as a submenu item from the main menu bar. What code is necessary to do this?
This is what I know so far:
In the 'Docked Window' under the 'Rescource' tab and the subfolder marked 'Menu' are two IDR objects. One is the default IDR_MAINFRAME, the other is the IDR_PROJECTNAME.
If the project IDR is selected, the current available menu items are displayed in the workspace. From here on, I need help. What steps make it possible to launch an exe from the menu item I select?
I'm guessing that I should select the menu item in which the exe should appear as a submenu item. Then, from that dropdown list, select the blank box listed as the last submenu item, choose properties, select an 'ID:' from the dropdown box, type in a caption in the Caption Box. Even if I'm correct in these steps, I'm sure some code needs to be inserted somewhere.
This is where I need help, can you help me with these steps?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Lionel,
Thanks for the response. I have 'zilch' MFC experience. This task will be my first introduction to Windows/MFC programming.
Up until now, I've had two courses in data structures and one operating systems course which got my feet wet to programming, but that's it.
Some of the terms you mentioned left me in the dust.
Starting from:
"Create in your frame a member function to handle the menu message from this item."
Can you define 'frame' or how I access it? Does this have anything to do with the ClassWizard, or can I access the 'frame' using the ClassWizard? I can see from within the ClassWizard that a block of empty space/code has already been allotted for this menu item and it looks like this:
void CProjectHelpMenu::OnProjec thelp()
{
// Call Help file
ShellExecute("Projecthelp. hlp", SW_SHOW);
}
I think the above code satisfies the portion you define as:
// in the .CPP"
But I still have questions. Should the full file path of 'Projecthelp.hlp' be displayed like "C:\Help\ProjectHelp.hlp", SW_SHOW)
How do I access the .h file you mentioned to perform the following:
// in the .H of your frame
afx_msg void OnMyMenuSelected();
After I knock that out, I'll just need help on assigning my function to the menu item message.
Thanks!
Thanks for the response. I have 'zilch' MFC experience. This task will be my first introduction to Windows/MFC programming.
Up until now, I've had two courses in data structures and one operating systems course which got my feet wet to programming, but that's it.
Some of the terms you mentioned left me in the dust.
Starting from:
"Create in your frame a member function to handle the menu message from this item."
Can you define 'frame' or how I access it? Does this have anything to do with the ClassWizard, or can I access the 'frame' using the ClassWizard? I can see from within the ClassWizard that a block of empty space/code has already been allotted for this menu item and it looks like this:
void CProjectHelpMenu::OnProjec
{
// Call Help file
ShellExecute("Projecthelp.
}
I think the above code satisfies the portion you define as:
// in the .CPP"
But I still have questions. Should the full file path of 'Projecthelp.hlp' be displayed like "C:\Help\ProjectHelp.hlp",
How do I access the .h file you mentioned to perform the following:
// in the .H of your frame
afx_msg void OnMyMenuSelected();
After I knock that out, I'll just need help on assigning my function to the menu item message.
Thanks!
In a MFC non Dialog-box based application, the main window is called a Frame window. In a MDI application, a child window is called a Child Frame.
The class of a frame is CFrameWnd, which herits from the classical CWnd.
The wizard create a CMainFrame class for you, which herits from a CFrameWnd.
You can of course use the wizard to add this function.
BUT It seems that the wizard has already add the function to your project. So, you just have to add the ShellExecute function, as you mentionned it.
The class of a frame is CFrameWnd, which herits from the classical CWnd.
The wizard create a CMainFrame class for you, which herits from a CFrameWnd.
You can of course use the wizard to add this function.
BUT It seems that the wizard has already add the function to your project. So, you just have to add the ShellExecute function, as you mentionned it.
For the ShellExecute function, if the "slave" application is with you own app (in the same dir, for example), you don't need to give the full path. Only "slave.exe" is needed.
To access to the .H file, just double-clic on the name of the CMainFrame class, in the Project window of Visual Studio (the tree on the left of your screen)
This will open the .H.
This will open the .H.
Just ask for more details. You can also send me your code (only .CPP and .H files !!!!) here : lfumery@nordnet.fr
in order I see exactly your situation.
Good luck !
Lionel.
in order I see exactly your situation.
Good luck !
Lionel.
ASKER
Thanks, that did the trick
HWND ParentWindow = NULL;
char *FileName = "c:\\windows\\calc.exe";
ShellExecute(ParentWindow,
Bye,
Lionel.