Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

import menu from rc file


hello experts,

how can i import a menu from a rc file (see below for layout) to visual c++ 6?


layout:

134 MENU
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
{
POPUP "TRAY_POPUP"
{
  MENUITEM "Item1!", 32771
  MENUITEM SEPARATOR
  MENUITEM "Item2", 32772, CHECKED
  MENUITEM "Item3", 32783, CHECKED
  POPUP "&Sub1"
  {
    MENUITEM "SubItem1", 32775
    MENUITEM "SubItem2", 32782
  }
  MENUITEM "Item4", 32774
}
}
0
Mark_FreeSoftware
Asked:
Mark_FreeSoftware
  • 4
  • 3
1 Solution
 
mahesh1402Commented:
You want to load resource file located in another exe/dll ? if so you may use AfxFindResourceHandle / AfxSetResourceHandle to load resource from exe/dll.

use the win32 API  LoadMenu() function to load your menu from a resource file (.EXE or .DLL) , then use the win32 API  SetMenu() function to assigns a new menu to the specified window.

http://msdn.microsoft.com/library/us/winui/winui/windowsuserinterface/resources/menus/menureference/menufunctions/loadmenu.asp

http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/resources/menus/menureference/menufunctions/setmenu.asp

-MAHESH
0
 
Mark_FreeSoftwareAuthor Commented:

yes,i want to load resource file from another app,  but i want to modify the menu,
so i have to import it in visual c++ so i can alter it
0
 
mahesh1402Commented:
No dont need to import another application....you can load resource directly from another application exe/dll using AfxFindResourceHandle.

As I said above you retrieve resource handle of another application using AfxFindResourceHandle / AfxSetResourceHandle... and with LoadMenu you may load menu from resource of particular application / dll. Refer docs on above link for more info.

-MAHESH
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Mark_FreeSoftwareAuthor Commented:
>>you retrieve resource handle of another application using AfxFindResourceHandle / AfxSetResourceHandle... and with LoadMenu you may load menu

but how can i add extra items to the menu?
i must be missing somthing completely...
0
 
mahesh1402Commented:
Use CMenu MFC class..

Use CMenu::LoadMenu() to load menu from another application resource as said above and then use CMenu member functions CMenu::AppendMenu CMenu::InsertMenu to add / insert items to menu..

Refer :

http://msdn2.microsoft.com/en-us/library/177ay1x0.aspx

http://msdn2.microsoft.com/en-us/library/kb145b0a.aspx

http://msdn2.microsoft.com/en-us/library/89c2aa4b.aspx

-MAHESH
0
 
Mark_FreeSoftwareAuthor Commented:

thank you, i'll look into that at the end of this week
(busy for school now)
0
 
Mark_FreeSoftwareAuthor Commented:

thank you, works like a charm!
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now