Menu

Linking Menu Items

2007-07-10
2012-09-26
  • Nobody/Anonymous

    Hello everyone, I posted a message a couple weeks ago about writing menus. Now I would like to know how to link menu items to programs and windows like the open, save, save as windows and do stuff like select, delete, copy, paste (if anyone could tell me how to write the code for the select, copy, paste, delete stuff that would be great too!). My menu looks like this:
    MENU
    BEGIN

    POPUP "&File"
    BEGIN
        POPUP "&New"
        BEGIN 
        POPUP "&Record New Audio File"
        BEGIN
        MENUITEM "&Record New WAV File", IDM_FILENEWRECWAV
        MENUITEM "&Record New MP3 File", IDM_FILENEWRECMP3
        MENUITEM "&Record New MP2 File", IDM_FILENEWRECMP2
        END
        MENUITEM "&New Text File", IDM_FILENEWTXT
        MENUITEM "&New Microsoft Word Document", IDM_FILENEWDOC
        MENUITEM "&New Microsoft Excel Book", IDM_FILENEWXLS
        MENUITEM "&New Microsoft PowerPoint Presentation", IDM_FILENEWPPT
        END
        MENUITEM "&Add File To Library\tCtrl+O", IDM_FILEOPEN
    MENUITEM "&Add Folder To Library", IDM_FOLDEROPEN
        MENUITEM "&Save Library\tCtrl+S", IDM_FILESAVE
    MENUITEM "Save Library &As", IDM_FILESAVEAS
    MENUITEM SEPARATOR
    MENUITEM "&Print\tCtrl+P", IDM_FILEPRINT
    MENUITEM "Page Se&tup", IDM_FILEPAGESETUP
    MENUITEM SEPARATOR
    MENUITEM "E&xit\tAlt+F4", IDM_FILEEXIT
    END
    
    POPUP "&Edit"
    BEGIN
    MENUITEM "&Undo\tCtrl+Z", IDM_EDITUNDO
    MENUITEM SEPARATOR
    MENUITEM "&Cut\tCtrl+X", IDM_EDITCUT
    MENUITEM "&Copy\tCtrl+C", IDM_EDITCOPY
    MENUITEM "&Paste\tCtrl+V", IDM_EDITPASTE
    MENUITEM SEPARATOR
    MENUITEM "&Delete\tDel", IDM_EDITDELETE
    MENUITEM "&Select All\tCtrl+A", IDM_EDITSELECTA
    MENUITEM "&Select None\tCtrl+Shift+A", IDM_EDITSELECTN
    MENUITEM "&Select 1\tCtrl+1", IDM_EDITSELECT1
    END
    
    POPUP "&Help"
    BEGIN
    MENUITEM "&About", IDM_HELPABOUT
    END
    

    END
    Thank you!

     
    • Anonymous

      Anonymous - 2007-07-10

      You seem to be asking very basic questions about Win32 GUI programming, and getting your information this way will result in very slow progress. Get yourself some Win32 reference material (such as Petzold's Win32 Programming) where this will certainly be covered.

      Basically selecting menu item results in a WM_COMMAND message being passed to your program's message loop. When this occurs, the wParam parameter contains the menu ID as specified in the resource (IDM_FILESAVE for example). You write your message loop to check for WM_COMMAND and then call an appropriate handler (or inline the handler code) depending on wParam. An example can be found at http://omnimaga.org/ar/t1124.htm for example (I just Google'd "IDM_FILESAVE" to find that example, I am not suggesting that it is a good or bad example - find your own its that easy!)

      There are also a number of examples provided with Dev-C++!

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.