?? tc20寫的dos底下文本菜單.htm
字號:
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 = &SubMenu[MainMenu. select];<BR>break ;<BR>case
RETURN :<BR>Exitmenu (MainMenu.select );<BR>return
mn->COMMAND_ID[mn->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, &count
,&totallen ,&maxlen) ;<BR><BR>MainMenu.itemnum =count
;<BR>beginx=3;<BR>for(i=
0;i<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 ,
&count , &i , &maxlen) ;<BR>SubMenu[ord].itemname = name
;<BR><BR>SubMenu [ord].itemnum =count
;<BR>j=maxlen+1;<BR>if(j+MainMenu.itemcoor[4 * ord]<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<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<<4|BLACK);<BR>for(i= 0 ;i<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<<4|BLACK)
;<BR>}<BR>}<BR><BR>char *textbuf;<BR><BR>int DisplaySubMenu (int ord
)<BR>{<BR>unsigned size , i;<BR>MENUTYPE * mn = &SubMenu[ord]
;<BR>textbuf=NULL;<BR>textbuf=malloctextbuf(mn->coor[2]-mn->coor[0]+1+2,<BR>mn->coor[3]-mn->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->coor[1]==mn->coor[3])<BR>return
0;<BR>gettextxy(mn->coor[0],mn->coor[1],<BR>mn->coor[2]-mn->coor[0]+1+2,<BR>mn->coor[3]-mn->coor[1]+1+1,textbuf);<BR><BR>drawbox(mn->coor[0],mn->coor[1],<BR>mn->coor[2]-mn->coor[0]+1,<BR>mn->coor[3]-mn->coor[1]+1,edge,WHITE<<4|BLACK,"");<BR><BR>for(i
=0;i<mn->itemnum
;i++)<BR>{<BR>if(i==mn->select)<BR>In_ActiveSubMenuItem(ord , i ,
1);<BR>else<BR>{<BR>cprintfxy(mn->itemdispxy[i*2],mn->itemdispxy[i*2+1],mn->itemname[i],WHITE<<4|BLACK);<BR>}<BR>}<BR>return
0 ;<BR><BR>}<BR><BR><BR>static void Exitmenu (int ord
)<BR>{<BR>MENUTYPE *mn=&SubMenu[ord]
;<BR>if(textbuf)<BR>{<BR>puttextxy(mn->coor[0],mn
->coor[1],mn->coor[2]-mn->coor[0]+1+2,<BR>mn->coor[3]-mn->coor[1]+1+1,textbuf);<BR>free
(textbuf);<BR>}<BR>}<BR><BR>void In_ActiveMainMenuItem(int select ,
char In_Active)<BR>{<BR>MENUTYPE * tp = &MainMenu
;<BR><BR><BR>if (In_Active==0) /* H off w */<BR>{<BR>cprintfxy
(tp->itemdispxy[select * 2] ,<BR>tp->itemdispxy[select * 2+ 1]
,<BR>tp ->itemname [select],(WHITE<<4)|BLACK)
;<BR>}<BR>else<BR>{<BR>cprintfxy (tp->itemdispxy[select * 2]
,<BR>tp->itemdispxy[select * 2+1] ,<BR>tp ->itemname
[select],(GREEN<<4)|BLUE) ;<BR>}<BR>}<BR><BR>void
In_ActiveSubMenuItem(int ord , int select , char
In_Active)<BR>{<BR>MENUTYPE * tp =&SubMenu[ord] ;<BR>if
(In_Active==0) /* w off w
*/<BR>{<BR>cprintfxy(tp->itemdispxy[select * 2] ,<BR>tp
->itemdispxy[select * 2+1],<BR>tp ->itemname
[select],(WHITE<<4)|BLACK) ;<BR>}<BR>else<BR>{<BR>cprintfxy
(tp->itemdispxy[select * 2] ,<BR>tp->itemdispxy[select *2+
1],<BR>tp ->itemname[select],(GREEN<<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<<8)<BR>{<BR>key=key&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>(*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>x2)<BR>{<BR>x =
x1; x1= x2; x2=x;<BR>}<BR>if (y1>y2)<BR>{<BR>x=y1;y1
=y2;y2=x;<BR>}<BR>if(y1<1)<BR>y1=1;<BR>if(y2>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<=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<=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)>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<<4|RED,"
MessageBox
");<BR>cprintfxy(MidX-strlen(Message)/2,MidY-1,Message,GREEN<<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>1;
i-=2)<BR><BR>{<BR><BR>attrib= gettextattrib(i,14);<BR>cprintfxy(i
,14, "Menu example !",((BLUE<<4)&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<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© </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 + -