Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Adding items to menu bar(similar to Add to favourites)

Adding items to menu bar(similar to Add to favourites)

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aditya Rao
    wrote on last edited by
    #1

    hi, i have a SDI application in which i want to add some text on the menus. for example the way we have the Add to Favourites in the Internet Explorer menu. so how do i implement that in my application. but in this case i want the data in a text box to be added (functionality is same as that of the Add to Favourites) . can anyone help. thanks aditya

    K T 2 Replies Last reply
    0
    • A Aditya Rao

      hi, i have a SDI application in which i want to add some text on the menus. for example the way we have the Add to Favourites in the Internet Explorer menu. so how do i implement that in my application. but in this case i want the data in a text box to be added (functionality is same as that of the Add to Favourites) . can anyone help. thanks aditya

      K Offline
      K Offline
      khan
      wrote on last edited by
      #2

      To insert a new item: CMenu* m; m = AfxGetApp()->GetMainWnd()->GetMenu(); m = m->GetSubMenu(2);//change this to whatever (zero-based index). m->AppendMenu(MF_ENABLED,253,"new item");//change the second parameter to something you like. and the third one too. When the menu item is clicked, you need a menu-command-range hander in the message-map macro in the .cpp file: ON_COMMAND_RANGE(200,400,OnMyMenu)//change the first and second parameter to the range you will provide in the second param to AppendMenu() The implementation will be: void CMySdiView::OnMyMenu(UINT nItem) { } Now nItem contains the second parameter you gave in AppendMenu(). So you know which one was clicked. One thing to note is that you must have at least a sub-item in the menu in the resource. Let it be a separator. When no sub-items are present, it gives a headache. this is this.

      1 Reply Last reply
      0
      • A Aditya Rao

        hi, i have a SDI application in which i want to add some text on the menus. for example the way we have the Add to Favourites in the Internet Explorer menu. so how do i implement that in my application. but in this case i want the data in a text box to be added (functionality is same as that of the Add to Favourites) . can anyone help. thanks aditya

        T Offline
        T Offline
        Tim Zorn
        wrote on last edited by
        #3

        first u have to get a handle to the menu or create ur own HMENU hMenu = CreateMenu(); HMENU hPMenu = CreatePopupMenu(); AppendMenu(hMenu,MF_STRING|MF_POPUP,(UINT_PTR)hPMenu,favmenuTxt); AppendMenu(hPMenu,MF_STRING,favID,favTxt); also in ur message process u need to handle for the WM_COMMAND message with (i think) wParam being the command ID

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups