473,322 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

navigate down in submenu

i create program that create menu and sub-menu
user have the ability to move up and down in parent menu and only have the ability to move down in sub-menu

the problem that when user navigate through sub-menu down the sub-menu disappear and i do not want that any solution i now it is easy with functions to create but i need it without function my code

Expand|Select|Wrap|Line Numbers
  1. #define ENTER 13
  2. #define ESCAP 27
  3. #define HOME  71
  4. #define UP    72  
  5. #define DOWN  80
  6. #define END  79
  7. #define TAB  9
  8. #include<conio.h>
  9. #include<stdio.h>
  10.  
  11.  int main()
  12.   {
  13.     char ch,names[3][10]={"new","display","exit"},newMenu[3][10]={"file","proper","edit"};
  14.     int i,flag=0,pos=0,subpos=0,j;
  15.      do{
  16.      clrscr();
  17.      for(i=0;i<3;i++)
  18.       {
  19.          gotoxy(5,i+1);
  20.          if(i==pos)
  21.            textattr(0x70+BLINK);
  22.            cprintf("%s",names[i]);
  23.            textattr(0x07);
  24.       }
  25.      ch=getch();
  26.         switch(ch)
  27.          {
  28.            case ENTER:
  29.                switch(pos)
  30.                   {
  31.                     case 0:
  32.                     case 1:
  33.                         clrscr();
  34.                         printf("%s \t press any key to return main menu",names[pos]);
  35.                         ch=getch();
  36.                         break;
  37.                     case 2:
  38.                          flag=1;
  39.                          break;
  40.                   }
  41.                   break;
  42.               case ESCAP:
  43.                   flag=1;
  44.                   break;
  45.               case TAB:
  46.                   pos++;
  47.                   if(pos >2)
  48.                   pos=0;
  49.                   break;
  50.               case NULL:
  51.                    ch=getch();
  52.                       switch(ch)
  53.                        {
  54.                          case HOME: //home
  55.                              pos=0;
  56.                              break;
  57.                          case UP: //up
  58.                              pos--;
  59.                              if(pos<0)
  60.                               pos=2;
  61.                              break;
  62.                          case DOWN:
  63.  
  64.                               pos++;
  65.                               if(pos>2)
  66.                                pos=0;
  67.                               break;
  68.                          case END:
  69.                               pos=2;
  70.                               break;
  71.                          case 77: //right arrow
  72.                                 switch(pos)
  73.                                  {
  74.                                     case 0:  //new highlted
  75.                                     do{
  76.                                       for(j=0;j<3;j++){
  77.                                            gotoxy(13,j+2);
  78.                                            if(subpos == j)
  79.                                                textattr(RED+BLINK);
  80.                                               cprintf("%s",newMenu[j]);
  81.                                               textattr(WHITE);
  82.                                         }//end for
  83.  
  84.                                        ch=getch();
  85.                                           switch(ch)
  86.                                             {
  87.                                                case NULL:
  88.                                                     ch=getch();
  89.                                                        switch(ch)
  90.                                                          {
  91.                                                             case DOWN:
  92.                                                               subpos++;
  93.                                                               if(subpos == 2)
  94.                                                                 subpos = 0;
  95.                                                              break;
  96.                                                          }
  97.                                                break;//end  null case
  98.                                             }//end switch ch 2nd step of coposite
  99.                                        break;//end case 0
  100.  
  101.                                        }while(1);
  102.                                  }//end switch pos
  103.  
  104.                               break; //end Null case
  105.  
  106.                        }//end switch
  107.  
  108.                   break; // end case 77
  109.                default :
  110.                   flag = 1;
  111.                   break;
  112.          }
  113.       }while(flag == 0);
  114.     return 0;
  115.   }

Oct 16 '14 #1
2 1088
Have you ever checked your functions you might missed a variable or something.
Oct 16 '14 #2
i posted it here because i do not know what is missing
Oct 16 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John Doe | last post by:
I've made this simple menu using a javascript : http://larsandre.mine.nu/menu.htm If I select one of the menu items the submenu appears just fine, my only problem is that If I point the mouse...
10
by: Haines Brown | last post by:
I've implemented the horizontal drop down menu discussed recently in this newsgroup, and it works nicely under Galeon and Mozilla, but not IE 5.0. Here are the problems: Under IE 5.0, the...
0
by: vikram.cvk | last post by:
Hello Experts, Im trying to design a CSS vertical drop down menu which should have the following functionality. Home About Us | -->Overview
15
by: firstcustomer | last post by:
Further to my earlier post, I've found something that does partly what I'm doing, but there are two issues: 1) There is an error in the script. Being a Javascript newbie, I've no idea what the...
4
by: Enrika | last post by:
Greetings! I'm working on a CSS drop-down menu, which, to my surprise, is actually working, more-or-less, in both IE *and* Firefox (and Netscape). But there are two changes that I want to make that...
5
by: Jonathan | last post by:
Hello All, I am in the process of creating a 2/3 level collapsible/exspanible menu (called "nav") where users can click on a category and have the submenus appear beneath it and so on (allow...
0
Denburt
by: Denburt | last post by:
This code is for a Toggle Button layout on a form, with this code you can set a number of toggle buttons visible and have multiple submenus that will stay hidden when not in use. My main menu is set...
1
by: priscbean | last post by:
I'm a total newbie. I really need help with this script. Its a drop down menu formatted with a CSS. It's not a formatting issue but i can't get the JS to run. I think I'm having issues calling it or...
0
by: buzzard724 | last post by:
Ul li drop down menu works in FF not quite in IE Thank you for looking at this. The page is generated dynamically by php, js and jquery. The drop down menu ul- reports-li - works fine in FF. In...
1
by: c s h | last post by:
Now creating my first website. I'm making my menu from a nested ul then manipulating it with CSS by the default the submenu items are not right below the parent they jump down as I hover over them...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.