Something is wrong with this menu...

This is a discussion on Something is wrong with this menu... within the Windows Programming forums, part of the Platform Specific Boards category; as you know, i dont use a resource editor, so i type everything by hand, and for soe reason this ...

  1. #1
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343

    Something is wrong with this menu...

    as you know, i dont use a resource editor, so i type everything by hand, and for soe reason this menu will not work right! everything is structured perfectly, only problem is, is that, well, there are 4 menus up top in the main menu bar called "hmenu" and form there on its all basically a heiachy of popup menus. its supposed to have:
    DarkCode Edit Code Quik Code Help
    and they each have a slew of menus undernethe them. bot for some reason it loks like this:
    Edit Code Quik Code Help
    and nothing pops up under EditCode. QuikCode and help work fine, those are noraml, but something is completely awry, and it has had me frustrated for 3 days. at first, it looked like this:
    Help
    with everything under that and i got to this point. but now i cant figure out whats wrong. someone help!!!!!

    Code:
    case WM_CREATE:
    			HMENU hmenu;
    			hmenu = CreateMenu ();
    			MENUITEMINFO mii;
    			mii.cbSize = sizeof(MENUITEMINFO);
    			mii.fMask = MIIM_TYPE | MIIM_ID;
    			mii.fType = MFT_STRING;
    			char *string;
    			string = new char[40];
    			
    				HMENU darkcode;
    				darkcode = CreatePopupMenu ();
    				
    				lstrcpy (string, "New DarkCode");
    				mii.fMask = MIIM_TYPE | MIIM_ID;
    				mii.wID = 1;
    				InsertMenuItem(darkcode, 1, TRUE, &mii);
    				
    					HMENU opencode;
    					opencode = CreatePopupMenu ();
       							
    					lstrcpy (string, "DarkCode Document");
    					mii.fMask = MIIM_TYPE | MIIM_ID;
    					mii.wID = 2;
    					InsertMenuItem(opencode, 1, TRUE, &mii);
    					
         				lstrcpy (string, "HTML Document");
    					mii.fMask = MIIM_TYPE | MIIM_ID;
    					mii.wID = 4;
    					InsertMenuItem(opencode, 2, TRUE, &mii);
    					
    					lstrcpy (string, "JavaScript");
    					mii.wID = 5;
    					InsertMenuItem(opencode, 3, TRUE, &mii);
    					
    					lstrcpy (string, "Cascading Style Sheet");
    					mii.wID = 6;
    					InsertMenuItem(opencode, 4, TRUE, &mii);
    					
    					lstrcpy (string, "Javascript Style Sheet");
    					mii.wID = 7;
    					InsertMenuItem(opencode, 5, TRUE, &mii);
    					
    					lstrcpy (string, "Perl Script");
    					mii.wID = 8;
    					InsertMenuItem(opencode, 6, TRUE, &mii);
    					
    					lstrcpy (string, "CGI Script");
    					mii.wID = 9;
    					InsertMenuItem(opencode, 7, TRUE, &mii);
    					
    					lstrcpy (string, "PHP Document");
    					mii.wID = 10;
    					InsertMenuItem(opencode, 8, TRUE, &mii);
    					
    					lstrcpy (string, "Active Server Page Script");
    					mii.wID = 11;
    					InsertMenuItem(opencode, 9, TRUE, &mii);
    					
    					lstrcpy (string, "C Code");
    					mii.wID = 12;
    					InsertMenuItem(opencode, 10, TRUE, &mii);
    					
    					lstrcpy (string, "C++ Code");
    					mii.wID = 13;
    					InsertMenuItem(opencode, 11, TRUE, &mii);
    					
    					lstrcpy (string, "C# Code");
    					mii.wID = 14;
    					InsertMenuItem(opencode, 12, TRUE, &mii);
    					
    					lstrcpy (string, "C Header File");
    					mii.wID = 15;
    					InsertMenuItem(opencode, 13, TRUE, &mii);
    					
    					lstrcpy (string, "C Resource Script");
    					mii.wID = 16;
    					InsertMenuItem(opencode, 14, TRUE, &mii);
    					
    				// the submenu of ^^^^^^^^^^ those
        			lstrcpy (string, "Open Code");
    				mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
    				mii.hSubMenu = opencode;
    				InsertMenuItem(darkcode, 2, TRUE, &mii);
    				
    				lstrcpy (string, "Save Code");
    				mii.fMask = MIIM_TYPE | MIIM_ID;
    				mii.wID = 17;
    				InsertMenuItem(darkcode, 3, TRUE, &mii);
    				
         				HMENU exportcode;
    					exportcode = CreatePopupMenu();
    						
    						lstrcpy (string, "HTML Document");
    						mii.fMask = MIIM_TYPE | MIIM_ID;
    						mii.wID = 18;
    						InsertMenuItem(exportcode, 1, TRUE, &mii);
    						
    						lstrcpy (string, "JavaScript");
    						mii.wID = 19;
    						InsertMenuItem(exportcode, 2, TRUE, &mii);
    						
    						lstrcpy (string, "Cascading Style Sheet");
    						mii.wID = 20;
    						InsertMenuItem(exportcode, 3, TRUE, &mii);
    						
    						lstrcpy (string, "Javascript Style Sheet");
    						mii.wID = 21;
    						InsertMenuItem(exportcode, 4, TRUE, &mii);
    						
    						lstrcpy (string, "Perl Program");
    						mii.wID = 22;
    						InsertMenuItem(exportcode, 5, TRUE, &mii);
    						
    						lstrcpy (string, "CGI Program");
    						mii.wID = 23;
    						InsertMenuItem(exportcode, 6, TRUE, &mii);
    						
    						lstrcpy (string, "PHP Document");
    						mii.wID = 24;
    						InsertMenuItem(exportcode, 7, TRUE, &mii);
    						
    						lstrcpy (string, "Active Server Page");
    						mii.wID = 25;
    						InsertMenuItem(exportcode, 8, TRUE, &mii);
    						
    						lstrcpy (string, "C File");
    						mii.wID = 26;
    						InsertMenuItem(exportcode, 9, TRUE, &mii);
    						
    						lstrcpy (string, "C++ File");
    						mii.wID = 27;
    						InsertMenuItem(exportcode, 10, TRUE, &mii);
    						
    						lstrcpy (string, "C# File");
    						mii.wID = 28;
    						InsertMenuItem(exportcode, 11, TRUE, &mii);
    						
    						lstrcpy (string, "C Header File");
    						mii.wID = 29;
    						InsertMenuItem(exportcode, 12, TRUE, &mii);
    						
    						lstrcpy (string, "C Resource Script");
    						mii.wID = 30;
    						InsertMenuItem(exportcode, 13, TRUE, &mii);
    						
    					lstrcpy (string, "Export Code");
    					mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
    					mii.hSubMenu = exportcode;
    					InsertMenuItem(darkcode, 4, TRUE, &mii);
    					
    					lstrcpy (string, "Print Code");
    					mii.fMask = MIIM_TYPE | MIIM_ID;
    					mii.wID = 31;
    					InsertMenuItem(darkcode, 5, TRUE, &mii);
    					
    					lstrcpy (string, "Exit DarkCode");
    					mii.wID = 32;
    					InsertMenuItem(darkcode, 6, TRUE, &mii);
    
    				lstrcpy (string, "DarkCode");
    				mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
    				mii.hSubMenu = darkcode;
    				InsertMenuItem(hmenu, 1, TRUE, &mii);
    				
    					HMENU eMenu;
    					eMenu = CreatePopupMenu();
    					
    						lstrcpy (string, "Undo");
    						mii.fMask = MIIM_TYPE | MIIM_ID;
    						mii.wID = 33;
    						InsertMenuItem(eMenu, 1, TRUE, &mii);
    						
    						lstrcpy (string, "Copy");
    						mii.wID = 34;
    						InsertMenuItem(eMenu, 2, TRUE, &mii);
    						
    						lstrcpy (string, "Paste");
    						mii.wID = 35;
    						InsertMenuItem(eMenu, 3, TRUE, &mii);
    						
    						lstrcpy (string, "Cut");
    						mii.wID = 36;
    						InsertMenuItem(eMenu, 4, TRUE, &mii);
    						
    					lstrcpy (string, "Edit Code");
    					mii.dwTypeData = string;
    					mii.cch = lstrlen (string);
    					mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
    					mii.hSubMenu = eMenu;
    					InsertMenuItem(hmenu, 2, TRUE, &mii);
    					
    					HMENU codesnip;
    					codesnip = CreatePopupMenu();
    						
    						HMENU htmlcode;
    						htmlcode = CreatePopupMenu();
    						
    							lstrcpy (string, "Basic Setup");
    							mii.fMask = MIIM_TYPE | MIIM_ID;
    							mii.wID = 37;
    							InsertMenuItem(htmlcode, 0, FALSE, &mii);
    							
    					lstrcpy (string, "HTML");
    					mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
    					mii.hSubMenu = htmlcode;
    					InsertMenuItem(codesnip, 1, TRUE, &mii);
    						
    						HMENU javascriptcode;
    						javascriptcode = CreatePopupMenu();
    						
    							lstrcpy (string, "Basic Startup");
    							mii.fMask = MIIM_TYPE | MIIM_ID;
    							mii.wID = 38;
    							InsertMenuItem(javascriptcode, 0, FALSE, &mii);
    							
    					lstrcpy (string, "JavaScript");
    					mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
    					mii.hSubMenu = javascriptcode;
    					InsertMenuItem(codesnip, 2, TRUE, &mii);
    					
    						HMENU csscode;
    						csscode = CreatePopupMenu();
    							
    							lstrcpy (string, "Basic Setup");
    							mii.fMask = MIIM_TYPE | MIIM_ID;
    							mii.wID = 39;
    							InsertMenuItem(csscode, 0, FALSE, &mii);
    							
    					lstrcpy (string, "CSS");
         				mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
         				mii.hSubMenu = csscode;
             			InsertMenuItem(codesnip, 3, TRUE, &mii);
             			
             				HMENU perlcode;
             				perlcode = CreatePopupMenu();
             				
             					lstrcpy (string, "Basic Setup");
                      			mii.fMask = MIIM_TYPE | MIIM_ID;
                         		mii.wID = 40;
                           		InsertMenuItem(perlcode, 0, FALSE, &mii);
                        
                        lstrcpy (string, "Perl");
                        mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
                        mii.hSubMenu = perlcode;
                       	InsertMenuItem(codesnip, 4, TRUE, &mii);
                       	
                       		HMENU phpcode;
                       		phpcode = CreatePopupMenu();
                       			
              				lstrcpy (string, "Basic Setup");
               			    mii.fMask = MIIM_TYPE | MIIM_ID;
               			    mii.wID = 41;
               			    InsertMenuItem(phpcode, 0, FALSE, &mii);
               			    
          			    lstrcpy (string, "PHP");
                 		mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
                 		mii.hSubMenu = phpcode;
                 		InsertMenuItem(codesnip, 5, TRUE, &mii);
                 		
                 			HMENU aspcode;
                 			aspcode = CreatePopupMenu();
                 			
                 			lstrcpy (string, "Basic Setup");
                 			mii.fMask = MIIM_TYPE | MIIM_ID;
                 			mii.wID = 42;
                 			InsertMenuItem(aspcode, 0, FALSE, &mii);
                 			
          			   lstrcpy (string, "ASP");
          			   mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
          			   mii.hSubMenu = aspcode;
          			   InsertMenuItem(codesnip, 6, TRUE, &mii);
    				   
    				   		HMENU ccode;
    				   		ccode = CreatePopupMenu();
    				   		
    				   		lstrcpy (string, "NONE");
    				   		mii.fMask = MIIM_TYPE | MIIM_ID;
    				   		mii.wID = 43;
    				   		InsertMenuItem(ccode, 0, FALSE, &mii);
    				   		
    		   		  lstrcpy (string, "C");
    		   		  mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
    		   		  mii.hSubMenu = ccode;
    		   		  InsertMenuItem(codesnip, 7, TRUE, &mii);
    		   		  
    		   		  		HMENU cppcode;
    		   		  		cppcode = CreatePopupMenu();
    		   		  		
    		   		  		lstrcpy (string, "Console - Setup");
    		   		  		mii.fMask = MIIM_TYPE | MIIM_ID;
    		   		  		mii.wID = 44;
    		   		  		InsertMenuItem(cppcode, 0, FALSE, &mii);
    		   		  		
    		   		  		lstrcpy (string, "Console - Hello World");
    		   		  		mii.wID = 45;
    		   		  		InsertMenuItem(cppcode, 0, FALSE, &mii);
    		   		  		
       		  		  lstrcpy(string, "C++");
       		  		  mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
       		  		  mii.hSubMenu = cppcode;
       		  		  InsertMenuItem(codesnip, 8, TRUE, &mii);
       		  		  
       		  		  		HMENU csharpcode;
       		  		  		csharpcode = CreatePopupMenu();
       		  		  		
       		  		  		lstrcpy (string, "NONE");
    		   		  		mii.fMask = MIIM_TYPE | MIIM_ID;
    		   		  		mii.wID = 46;
    		   		  		InsertMenuItem(csharpcode, 0, FALSE, &mii);
    		   		  		
       		  		 lstrcpy(string, "C#");
       		  		  mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
       		  		  mii.hSubMenu = csharpcode;
    	  		     InsertMenuItem(codesnip, 9, TRUE, &mii);
    	  		     
    	  		     		HMENU javacode;
    	  		     		javacode = CreatePopupMenu();
       		  		  		
       		  		  		lstrcpy (string, "Basic Setup");
    		   		  		mii.fMask = MIIM_TYPE | MIIM_ID;
    		   		  		mii.wID = 47;
    		   		  		InsertMenuItem(javacode, 0, FALSE, &mii);
    		   		  		
       		  		 lstrcpy(string, "Java");
       		  		  mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
       		  		  mii.hSubMenu = javacode;
    	  		     InsertMenuItem(codesnip, 10, TRUE, &mii);
    	  		     
      		     lstrcpy(string, "Quik Code");
     		     mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
     		     mii.hSubMenu = codesnip;
     		     InsertMenuItem(hmenu, 3, TRUE, &mii);
     		     	
     		     	HMENU helpmenu;
     		     	helpmenu = CreatePopupMenu();
     		     	
     		     	lstrcpy (string, "Contextual HTML Help");
     		     	mii.fMask = MIIM_TYPE | MIIM_ID;
     		     	mii.wID = 48;
     		     	InsertMenuItem(helpmenu, 0, FALSE, &mii);
     		     	
     		     	lstrcpy (string, "About DarkCode v1");
     		     	mii.wID = 49;
     		     	InsertMenuItem(helpmenu, 0, FALSE, &mii);
     		     	
     		     	lstrcpy (string, "About DarkCode v1 (webpage)");
     		     	mii.wID = 50;
     		     	InsertMenuItem(helpmenu, 0, FALSE, &mii);
     		     	
     		     	lstrcpy (string, "Visit ViperVision.org");
     		     	mii.wID = 51;
     		     	InsertMenuItem(helpmenu, 0, FALSE, &mii);
     		     	
     		     	lstrcpy (string, "Visit DeadNight Entertainment");
     		     	mii.wID = 52;
     		     	InsertMenuItem(helpmenu, 0, FALSE, &mii);
     		     	
    	     	lstrcpy (string, "Help");
    	     	mii.fMask = MIIM_TYPE | MIIM_SUBMENU;
    	     	mii.hSubMenu = helpmenu;
    	     	InsertMenuItem(hmenu, 4, TRUE, &mii);
    	     	
        	SetMenu (hwnd, hmenu);
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Check your InsertMenuItem() indexes, they should start at item zero, and the item ID numbers for the callback. They both should not be repeated.

    #define ID_MENU_ITEM_FOR_CALLBACK 40001

    mii.wID = ID_MENU_ITEM_FOR_CALLBACK

    iMenuIndex [is zero based and I think goes down then across, into all popups first]

    InsertMenuItem(hMenu ,iMenuIndex ,TRUE ,&MenuItemInfo );

    don't forget

    MenuItemInfo.hSubMenu=???

    >>as you know, i dont use a resource editor

    In this case IMHO it would be better if you had. This is a large and complex menu.
    If I need to smash rocks I get my sledgehammer (resource editor) and if I want to crack a nut I use something more appropriate (append menu on the fly).
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343
    well, ok, ill make an .h file and program it with words for ID's, but as for not using a resource editor, you dont think ive tried???? whenever i compiler it keeps telling me ("afxres.h" no such file/or directory). and it wont compile. other than that, it just wont work. as for your other ideas, ill give that a try...thanx, anybody elses opinion would be great!
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating a menu that reads input via an array?
    By Nalif in forum C Programming
    Replies: 6
    Last Post: 09-29-2006, 09:21 PM
  2. Thoughts on Menu System for Book Inventory
    By curlious in forum C++ Programming
    Replies: 3
    Last Post: 09-29-2003, 03:32 AM
  3. Context Menu cursor problem
    By dWorkVan in forum Windows Programming
    Replies: 4
    Last Post: 07-14-2003, 11:42 AM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 11:01 AM
  5. Contexual Menu
    By Cgawd in forum Windows Programming
    Replies: 6
    Last Post: 11-24-2002, 03:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21