Menu

Adding menu items to examples

Anonymous
2002-11-09
2012-09-26
  • Anonymous

    Anonymous - 2002-11-09

    I am new to programming and am trying to learn by studying the examples. I have tried to add a seperator and "SelectAll" to the Edit menu in the WinMenu Example. I still can't figure out how to do this. Please help. When I attempt to add the item to the rc file or the source code and try to compile & run it, the compiler tells me that there are errors. Any ideas?

    Randal

     
    • Nobody/Anonymous

      if you are new you need to add th resource to it in a resource file

      so with this in the .h file add this

      #define IDMENU              1001
      #define ID_EXIT               1002

      in the rsrc.rc file
      IDMENU   MENU   PRELOAD DISCARDABLE  
      BEGIN
          POPUP "&File"
          BEGIN
          MENUITEM "menu", IDC_MENU //<----- resource
          END
      END
      the resource is often placed into a Res file and called though #include "resource.h" etc

      in the .c file there should be this lot of declares

          wincl.hInstance = hThisInstance;     // this instance
          wincl.lpszClassName = szClassName;  // class name
          wincl.lpfnWndProc = WindowProcedure;     // where to
                                                                                             // for
                                                                                            //procedure
          wincl.style = CS_DBLCLKS;                 // catch D clicks
          wincl.cbSize = sizeof(WNDCLASSEX);  // how big
          wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION); // icon
         /* to use*/
         wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
        /* same as above*/
         wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
        /* what cursor*/ 
         wincl.lpszMenuName = NULL;
        // and finally the menu commnad
      // change this to
      // wincl.lpszMenuName = GETMENUITEM(IDMENU);
         wincl.cbClsExtra = 0
         wincl.cbWndExtra = 0
         wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);

          /* Register the window class, if fail quit the program */
          if(!RegisterClassEx(&wincl)) return 0;

       

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.