⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tc20写的dos底下文本菜单.htm

📁 一些c的经典案例
💻 HTM
📖 第 1 页 / 共 3 页
字号:
            rightest w */<BR>MainMenu.select = 0;<BR>else<BR>MainMenu.select++ 
            ;<BR>In_ActiveMainMenuItem (MainMenu.select , 1);<BR>if 
            (DisplaySubMenu(MainMenu.select) ) /* # Out of memory w */<BR>return 
            -2 ;<BR>mn = &amp;SubMenu[MainMenu. select];<BR>break ;<BR>case 
            RETURN :<BR>Exitmenu (MainMenu.select );<BR>return 
            mn-&gt;COMMAND_ID[mn-&gt;select] ;<BR>}<BR>}<BR>}<BR><BR>void 
            LoadMainMenu()<BR>{<BR>int count ,totallen ,maxlen ,i;<BR>int 
            beginx;<BR>MainMenu.coor[0]= SCREENMINX;<BR>MainMenu.coor[1] 
            =SCREENMINY;<BR>MainMenu.coor[2] =SCREENMAXX;<BR>MainMenu.coor[3] 
            =SCREENMINY;<BR><BR>getitemcount(MainMenuItem, &amp;count 
            ,&amp;totallen ,&amp;maxlen) ;<BR><BR>MainMenu.itemnum =count 
            ;<BR>beginx=3;<BR>for(i= 
            0;i&lt;count;i++)<BR>{<BR>MainMenu.itemcoor[i*4] = beginx; /* w xl # 
            */<BR>MainMenu.itemcoor[i*4+1] = MainMenu.coor[1]; /* w yl w 
            */<BR>MainMenu.itemcoor[i*4+2] = beginx+strlen(MainMenuItem[i]); /* 
            # x2 # */<BR>MainMenu.itemcoor[i*4+3] = 
            MainMenu.coor[3];<BR><BR>MainMenu.itemdispxy[i*2] = beginx; /* w 
            actuall disp X w */<BR>MainMenu.itemdispxy[i*2+1] = 
            MainMenu.coor[3]; /* w actuall disp Y w 
            */<BR><BR>MainMenu.COMMAND_ID[i] = i 
            ;<BR><BR>beginx=beginx+strlen(MainMenuItem[i])+1;<BR>}<BR>MainMenu.itemname 
            = MainMenuItem ;<BR>}<BR><BR>void LoadSubMenu(char ** name ,int 
            ord)<BR>{<BR>int count ,i ,j ,maxlen;<BR>getitemcount(name , 
            &amp;count , &amp;i , &amp;maxlen) ;<BR>SubMenu[ord].itemname = name 
            ;<BR><BR>SubMenu [ord].itemnum =count 
            ;<BR>j=maxlen+1;<BR>if(j+MainMenu.itemcoor[4 * ord]&lt;WindowMaxX) 
            /* w left text justification is OK # */<BR>{<BR>SubMenu[ord].coor[0] 
            =MainMenu.itemcoor[4 * ord]; /*w item's xl w 
            */<BR>SubMenu[ord].coor[2] =SubMenu[ord].coor[0] +j ;<BR>}<BR>else 
            /* w Use right justification because of space w 
            */<BR>{<BR>SubMenu[ord].coor[2]=MainMenu.itemcoor[2]; /* # left just 
            use X2 w */<BR>SubMenu[ord].coor[0] =SubMenu[ord].coor[2] 
            -j;<BR>}<BR><BR>if(count==0)<BR>{<BR>SubMenu[ord].coor[1] 
            =SubMenu[ord].coor[1]+1; /* w The item's 
            y2*/<BR>SubMenu[ord].coor[3] 
            =SubMenu[ord].coor[1];<BR>}<BR><BR>else<BR>{<BR>SubMenu[ord].coor[1]=MainMenu.itemcoor[4*ord+3]+1;<BR>SubMenu[ord].coor[3]=SubMenu[ord].coor[1] 
            + 
            count+1;<BR>}<BR>for(i=0;i&lt;count;i++)<BR>{<BR>SubMenu[ord].itemcoor[i 
            * 4] =SubMenu[ord].coor[0]+1;<BR>SubMenu[ord].itemcoor[i * 
            4+1]=SubMenu[ord].coor[1]+i+1;<BR>SubMenu[ord].itemcoor[i * 4+2] 
            =SubMenu[ord].coor[2]-1;<BR>SubMenu[ord].itemcoor[i * 4+3] = 
            SubMenu[ord].itemcoor[i * 4+1] 
            +i+1;<BR><BR>SubMenu[ord].itemdispxy[i * 2] =SubMenu[ord].itemcoor[i 
            * 4];<BR>SubMenu[ord].itemdispxy[i * 2+1] =SubMenu[ord].itemcoor[i * 
            4+1];<BR>SubMenu[ord].COMMAND_ID[i] = ord * 100+i 
            ;<BR>}<BR>}<BR><BR>void DisplayMainMenu (void )<BR>{<BR>unsigned i 
            ;<BR>win(MainMenu.coor[0],MainMenu.coor[1],80,1,' 
            ',WHITE&lt;&lt;4|BLACK);<BR>for(i= 0 ;i&lt;MainMenu.itemnum 
            ;i++)<BR>{<BR>if(MainMenu.select==i)<BR>In_ActiveMainMenuItem (i , 
            1) ;<BR>else<BR>cprintfxy ( MainMenu.itemdispxy[i * 
            2],<BR>MainMenu.itemdispxy[i * 2+1] 
            ,<BR>MainMenu.itemname[i],WHITE&lt;&lt;4|BLACK) 
            ;<BR>}<BR>}<BR><BR>char *textbuf;<BR><BR>int DisplaySubMenu (int ord 
            )<BR>{<BR>unsigned size , i;<BR>MENUTYPE * mn = &amp;SubMenu[ord] 
            ;<BR>textbuf=NULL;<BR>textbuf=malloctextbuf(mn-&gt;coor[2]-mn-&gt;coor[0]+1+2,<BR>mn-&gt;coor[3]-mn-&gt;coor[1]+1+1);<BR>if(textbuf==NULL)<BR>{<BR>clrscr();<BR>printf("\nOut 
            of memory!");<BR>printf("\nPress any key...");<BR>getch();<BR>return 
            1;<BR>}<BR>if(mn-&gt;coor[1]==mn-&gt;coor[3])<BR>return 
            0;<BR>gettextxy(mn-&gt;coor[0],mn-&gt;coor[1],<BR>mn-&gt;coor[2]-mn-&gt;coor[0]+1+2,<BR>mn-&gt;coor[3]-mn-&gt;coor[1]+1+1,textbuf);<BR><BR>drawbox(mn-&gt;coor[0],mn-&gt;coor[1],<BR>mn-&gt;coor[2]-mn-&gt;coor[0]+1,<BR>mn-&gt;coor[3]-mn-&gt;coor[1]+1,edge,WHITE&lt;&lt;4|BLACK,"");<BR><BR>for(i 
            =0;i&lt;mn-&gt;itemnum 
            ;i++)<BR>{<BR>if(i==mn-&gt;select)<BR>In_ActiveSubMenuItem(ord , i , 
            1);<BR>else<BR>{<BR>cprintfxy(mn-&gt;itemdispxy[i*2],mn-&gt;itemdispxy[i*2+1],mn-&gt;itemname[i],WHITE&lt;&lt;4|BLACK);<BR>}<BR>}<BR>return 
            0 ;<BR><BR>}<BR><BR><BR>static void Exitmenu (int ord 
            )<BR>{<BR>MENUTYPE *mn=&amp;SubMenu[ord] 
            ;<BR>if(textbuf)<BR>{<BR>puttextxy(mn-&gt;coor[0],mn 
            -&gt;coor[1],mn-&gt;coor[2]-mn-&gt;coor[0]+1+2,<BR>mn-&gt;coor[3]-mn-&gt;coor[1]+1+1,textbuf);<BR>free 
            (textbuf);<BR>}<BR>}<BR><BR>void In_ActiveMainMenuItem(int select , 
            char In_Active)<BR>{<BR>MENUTYPE * tp = &amp;MainMenu 
            ;<BR><BR><BR>if (In_Active==0) /* H off w */<BR>{<BR>cprintfxy 
            (tp-&gt;itemdispxy[select * 2] ,<BR>tp-&gt;itemdispxy[select * 2+ 1] 
            ,<BR>tp -&gt;itemname [select],(WHITE&lt;&lt;4)|BLACK) 
            ;<BR>}<BR>else<BR>{<BR>cprintfxy (tp-&gt;itemdispxy[select * 2] 
            ,<BR>tp-&gt;itemdispxy[select * 2+1] ,<BR>tp -&gt;itemname 
            [select],(GREEN&lt;&lt;4)|BLUE) ;<BR>}<BR>}<BR><BR>void 
            In_ActiveSubMenuItem(int ord , int select , char 
            In_Active)<BR>{<BR>MENUTYPE * tp =&amp;SubMenu[ord] ;<BR>if 
            (In_Active==0) /* w off w 
            */<BR>{<BR>cprintfxy(tp-&gt;itemdispxy[select * 2] ,<BR>tp 
            -&gt;itemdispxy[select * 2+1],<BR>tp -&gt;itemname 
            [select],(WHITE&lt;&lt;4)|BLACK) ;<BR>}<BR>else<BR>{<BR>cprintfxy 
            (tp-&gt;itemdispxy[select * 2] ,<BR>tp-&gt;itemdispxy[select *2+ 
            1],<BR>tp -&gt;itemname[select],(GREEN&lt;&lt;4)|BLUE) 
            ;<BR>}<BR>}<BR><BR><BR>int GetKey(void){<BR>int 
            key;<BR>key=bioskey(0);<BR>if(key==F1)<BR>Help_page_show();<BR>else<BR>if(key&lt;&lt;8)<BR>{<BR>key=key&amp;0x00ff;<BR>if(isalpha(key))<BR>key=toupper(key);<BR>}<BR>return 
            key;<BR>}<BR><BR>static void getitemcount(char ** s ,int * count,int 
            * len,int * maxlen)<BR>{<BR>int i,j;<BR>for(( * 
            maxlen)=0,(*len)=0,i=0; s[i]!=NULL; i++)<BR>{<BR>j =strlen 
            (s[i]);<BR>(*len)+=j;<BR>if(j&gt;(*maxlen))<BR>( * maxlen) =j 
            ;<BR>}<BR>( *count)=i;<BR>}<BR><BR>void Draw(void)<BR>{<BR>int x, 
            x1, x2, y1, y2;<BR>randomize ( ) ;<BR>do<BR>{<BR>x1 = random 
            (WindowMaxX-WindowMinX) +WindowMinX ;<BR>y1 = random 
            (WindowMaxY-WindowMinY) +WindowMinY ;<BR>x2 = random 
            (WindowMaxX-WindowMinX) +WindowMinX ;<BR>y2 = random 
            (WindowMaxY-WindowMinY) +WindowMinY ;<BR>if (x1&gt;x2)<BR>{<BR>x = 
            x1; x1= x2; x2=x;<BR>}<BR>if (y1&gt;y2)<BR>{<BR>x=y1;y1 
            =y2;y2=x;<BR>}<BR>if(y1&lt;1)<BR>y1=1;<BR>if(y2&gt;23)<BR>y2=23;<BR>win(x1,y1,x2-y1+1,y2-y1+1,' 
            ',random(256));<BR>delay(100);<BR>}while(!bioskey(1));<BR>}<BR><BR>void 
            About (void)<BR>{<BR>char MidX, MidY, x1, y1, x2, y2, size;<BR>char 
            *buf1;<BR>MidX = (WindowMaxX - WindowMinX)/2 ;<BR>MidY = (WindowMaxY 
            - WindowMinY)/2 ;<BR>x1 = MidX-15;<BR>x2 = MidX+15;<BR>y1 = 
            MidY-4;<BR>y2 = 
            MidY+4;<BR>buf1=malloctextbuf(x2-x1+1+2,y2-y1+1+1);<BR>gettextxy(x1,y1,x2-x1+1+2, 
            y2-y1+1+1,buf1) ;<BR><BR>/* win(WindowMinX,WindowMinY,WindowMaxX, 
            WindowMaxY,' ',BLUE); */<BR>if ( 
            buf1==NULL)<BR>{<BR>clrscr();<BR>printf("\nOut of memory!Press any 
            key to exit...");<BR>getch ( ) 
            ;<BR>exit(1);<BR>}<BR>else<BR>{<BR>gettextxy(x1 ,y1 , 
            x2-x1+1+2,y2-y1+1+1, buf1) 
            ;<BR>drawbox(x1,y1,x2-x1+1,y2-y1+1,edge,WHITE," About... 
            ");<BR>cprintfxy(MidX-strlen("Menu Demo")/2,MidY-2,"Menu 
            Demo",RED);<BR>cprintfxy(MidX-strlen("In Text Mode")/2,MidY-1,"In 
            Text Mode",RED);<BR>cprintfxy(MidX-strlen("05/2000 
            By")/2,MidY,"05/2000 
            By",RED);<BR>cprintfxy(MidX-strlen("Howard.Hsu")/2,MidY+1,"Howard.Hsu",RED);<BR>cprintfxy(MidX-strlen(" 
            OK ")/2,MidY+2," OK ",GREEN);<BR>getch() 
            ;<BR>puttextxy(x1,y1,x2-x1+1+2,y2-y1+1+1,buf1);<BR>free 
            (buf1);<BR>}<BR>}<BR><BR>void DrawButtonUp(unsigned char 
            xpos,unsigned char ypos,<BR>char *message,char 
            attrib)<BR>{<BR>unsigned char len,i;<BR>char 
            BackAttrib;<BR>BackAttrib= 
            gettextattrib(xpos,ypos);<BR>len=strlen(message);<BR>prncharxy(xpos,ypos,' 
            ',attrib);<BR>cprintfxy(xpos+1,ypos,message,attrib);<BR>prncharxy(xpos+len+1,ypos,' 
            ',attrib);<BR>prncharxy(xpos+len+2,ypos,240,BackAttrib);<BR>for(i=0;i&lt;=len+2;i++)<BR>prncharxy(xpos+i+1,ypos+1,220,BackAttrib);<BR>return;<BR>}<BR><BR>void 
            DrawButtonDown(unsigned char xpos,unsigned char ypos,<BR>char 
            *message,char attrib)<BR>{<BR>unsigned char len,i;<BR>char 
            BackAttrib;<BR>BackAttrib= 
            gettextattrib(xpos,ypos+1);<BR>len=strlen(message);<BR>prncharxy(xpos,ypos,' 
            ',BackAttrib);<BR>prncharxy(xpos+1,ypos,' 
            ',attrib);<BR>cprintfxy(xpos+2,ypos,message,attrib);<BR>prncharxy(xpos+len+2,ypos,' 
            ',attrib);<BR>for(i=0;i&lt;=len+2;i++)<BR>prncharxy(xpos,ypos+1,' 
            ',BackAttrib);<BR>return;<BR>}<BR><BR><BR>void MessageBox(char * 
            Message)<BR>{<BR>int MidX, MidY, x1, y1, x2, y2, size, Len;<BR>char 
            *buf1;<BR>MidX = (WindowMaxX - WindowMinX)/2 ;<BR>MidY = (WindowMaxY 
            - WindowMinY)/2 ;<BR>Len = strlen(Message)&gt;strlen(" MessageBox 
            ")?strlen(Message):strlen(" MessageBox ");<BR>x1 = 
            MidX-Len;<BR>x2=MidX+Len;<BR>y1=MidY-4;<BR>y2=MidY+4;<BR>buf1=malloctextbuf(x2-x1+1+2,y2-y1+1+1);<BR>if 
            ( buf1==NULL)<BR>{<BR>clrscr();<BR>printf("\nOut of memory! Press 
            any key to continue...");<BR>getch( 
            );<BR>exit(1);<BR>}<BR>else<BR>{<BR>gettextxy(x1 ,y1 , 
            x2-x1+1+2,y2-y1+1+1, buf1) 
            ;<BR>drawbox(x1,y1,x2-x1+1,y2-y1+1,edge,GREEN&lt;&lt;4|RED," 
            MessageBox 
            ");<BR>cprintfxy(MidX-strlen(Message)/2,MidY-1,Message,GREEN&lt;&lt;4|BLUE);<BR><BR>DrawButtonUp(MidX-strlen("OK")/2-2,MidY+2,"OK",RED);<BR>getch();<BR>DrawButtonDown(MidX-strlen("OK")/2-2,MidY+2,"OK",RED);<BR>delay(5000);<BR><BR>puttextxy(x1 
            ,y1 ,x2-x1+1+2,y2-y1+1+1,buf1) ;<BR>free(buf1) 
            ;<BR>}<BR>}<BR><BR>void MoveText (void )<BR>{<BR>int i;<BR>char 
            attrib;<BR>win(0,1,80,23,' ',0);<BR>for (i=random(80); i&gt;1; 
            i-=2)<BR><BR>{<BR><BR>attrib= gettextattrib(i,14);<BR>cprintfxy(i 
            ,14, "Menu example !",((BLUE&lt;&lt;4)&amp;0x80)|RED) 
            ;<BR>delay(2000) ;<BR>cprintfxy(i,14, " 
            ",attrib);<BR><BR>}<BR>}<BR><BR>void GoodBye(char * pcInf1 , char * 
            pcInf2)<BR>{<BR>int f;<BR>clrscr ( );<BR>window(1 ,1 ,80,1) 
            ;<BR>textbackground (LIGHTBLUE ) ;<BR>clrscr() ;<BR>highvideo ( 
            );<BR>textcolor(WHITE);<BR>cprintf(pcInf1);<BR>textcolor(YELLOW);<BR>cprintf(pcInf2);<BR>window(1,1,80,25);<BR>printf("\n");<BR>for(f=400;f&lt;800;f+=100)<BR>{<BR>sound(f);<BR>delay(100);<BR>}<BR>nosound();<BR>exit(0);<BR>}<BR><BR><BR><BR> </P></TD>
          <TD style="FONT-SIZE: 12px" vAlign=top width=102 
        bgColor=#008000> </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV>
<TABLE height=65 cellSpacing=0 cellPadding=0 width=770 align=center 
background=TC20写的DOS底下文本菜单.files/bottom_line.gif border=0>
  <TBODY>
  <TR>
    <TD height=5> </TD></TR>
  <TR>
    <TD align=middle>
      <SCRIPT src=""></SCRIPT>

      <SCRIPT>var tc_user="adu520";var tc_class="2";</SCRIPT>

      <SCRIPT src=""></SCRIPT>

      <SCRIPT src=""></SCRIPT>
    </TD></TR>
  <TR>
    <TD align=middle>
      <DIV align=center><FONT face=Verdana, size=2 sans-serif Helvetica, 
      Arial,>CopyRight&copy; </FONT><FONT size=2 sans-serif helvetica, arial,>2003 
      </FONT><A href="http://adu520.yeah.net/"><STRONG><FONT color=#000000 
      size=2 sans-serif helvetica, arial,>乐知网络</FONT></STRONG></A><FONT 
      face=Verdana, size=2 sans-serif Helvetica, Arial,>All Rights 
      Reserved</FONT></DIV></TD></TR>
  <TR>
    <TD align=middle>
      <DIV align=center>
      <P align=center>未经授权禁止复制或建立镜像。谢谢!</P></DIV></TD></TR></TBODY></TABLE>
<SCRIPT src=""></SCRIPT>
</BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -