首页 > 技术文章 > C实现dos图文菜单程序实例

realhope 2015-03-07 12:03 原文

  前言

  公司一台服务器是novell环境,文件管理是基于dos6.22的,客户端启动需要一个图文菜单。

  实现

   编程环境:汉化版TC2.0

  菜单基本功能:显示提示项、显示dbf中的行情信息、跑马灯、时间提示。

  主要模块:1.汉字的显示 2.dbf库的读取 3.跑马灯显示 4.中断处理

   编码如下:

  1  /*               
  2 ver 2.1412051  
  3 Author :吴chunyuan                 
  4 last edit time:2014-12-5 
  5  深圳显示行情指数,分 10000点以上Ver 2.1412051    一万点以下 Ver 2.1412052  
  6 未解决问题:
  7  1 上海 4s 深圳 3s 行情同时刷新,SHARING_VIOLATION 错误,有待解决,没解决之前,hqsz=1 只刷新深圳行情
  8  
  9  2.如行情库是和深圳卫星接收行情同路径,且运行卫星接收程序,则一运行就 提示SHARING_VIOLATION 
 10 */
 11 #include "graphics.h" 
 12 #include "stdlib.h"   
 13 #include "malloc.h" 
 14 #include "bios.h"
 15 #include "stdio.h"   
 16 #include "dos.h"
 17 #include "conio.h"            
 18 #include "Wumenu.h"
 19 /*void *save;储存一块地方用的*/
 20 void init() 
 21 {        
 22 int a,b; 
 23 /*unsigned size;*/ 
 24 a=VGA;b=VGAHI;
 25 initgraph(&a,&b,"");
 26 gettime(&now);/*获取时间*/
 27 old=now.ti_sec;
 28 oldhq=old; 
 29 oldhq1=old;    
 30  /*size=imagesize(1,25,638,476);*/
 31  /*save=malloc(size);开辟存储空间*/
 32     
 33  setbkcolor(0);/*以下是开始界面初始化*/
 34  rectangle(1,25,638,476); /*整个画面*/
 35     
 36 rectangle(1,455,638,455); /* 第二层*/
 37       
 38 rectangle(1,455,140,476);/* 上海指数*/
 39     
 40 rectangle(1,455,279,476); /* 深圳指数*/
 41  
 42 rectangle(1,455,638,476);/*跑马灯,后显示制作人*/
 43 
 44 rectangle(1,435,638,455);/* 第一层 */
 45  /* rectangle(1,435,565,455);电话输出 */
 46 }
 47    
 48      
 49 main()     
 50              
 51     {   
 52         
 53         char strzt[50],strts[150],strts1[30],strts2[30],strts3[10],strts4[10],c,cshzs[8];
 54         /*char strsm1[50],strsm2[50],strsm3[50],strsm4[50],strsm5[50],strsm6[50];*/
 55          char * strsm[7];
 56           char * strxm[7]={"111111","211111","311111","411111","511111","611111"} ;
 57         /*char * strsm[7]={"111111111111111111111111111110","111111111111111111111111111211","111111111111111111111111111311","111111111111111111111111111411","1111111111111111111111151111111","111111111111111116111111111111"} ;
 58         */
 59          char * strt1[1]={"1111111111111111111111"};
 60         char * strt2[1]={"111111111111111111"};
 61          char * color[8]={"11","2","3","4","5","6","4","4"} ; /*   主题,菜单字,菜单底色,菜单说明,电话标题,屏幕底色,跑马灯,制作人*/
 62          char * hq[1]={"111111111111111111"};/*行情设置*/
 63           char * pm[1]={"111111111111111111"};/*跑马设置*/
 64           char * hqtime[1]={"111111111111111111"};/*行情刷新时间*/
 65         char * Line;
 66         int a,i,j,LEN,cl,hqsz,hqtimesz,pmsz;
 67         
 68          FILE *fppy;   
 69           init();              
 70         i=0; 
 71         Line=(char *)malloc(1200); /*值不够大客户端会出现死机*/
 72         
 73         if((fppy=fopen("./WucyM1.cfg","rb"))==NULL){
 74            printf("not find file WucyM.cfg ,QQ:41850709 \n");
 75           exit(1);} 
 76          
 77           fseek(fppy,0L,0);
 78         fgets(Line,120,fppy);
 79         field(1,Line,strzt);  /*提取主题*/ 
 80               
 81            
 82         fgets(Line,120,fppy);
 83 
 84          for(i=0;i<6;i++)  
 85         {     
 86            field(i+1,Line,strxm[i]);  /*提取菜单项目*/  
 87            LEN=i;
 88          if (strlen(strxm[i])<3) {strxm[i]='\0';LEN=i-1 ; break;}
 89           
 90         }      
 91               
 92         fgets(Line,120,fppy);
 93          
 94           
 95              
 96         for(i=0;i<LEN+1;i++)  
 97         { 
 98                strsm[i]=(char *)malloc(50);
 99             field(i+1,Line,strsm[i]); 
100         }       /*提取菜单说明*/
101         
102          
103          
104         fgets(Line,120,fppy);
105         field(1,Line,strt1[0]);  /*提取电话1*/
106          
107                  
108         fgets(Line,120,fppy);
109         field(1,Line,strt2[0]);  /*提取电话2*/
110          
111         fgets(Line,120,fppy);
112         field(1,Line,strts);  /*提取提示*/
113      
114         field(2,Line,strts1);  /*提取提示1*/  
115         
116          
117         field(3,Line,strts3);  /*提取提示3*/
118      
119         field(4,Line,strts4);  /*提取提示4*/
120         
121         
122         field(5,Line,strts2);  /*提取提示2,服务器名*/
123         
124                 
125         fgets(Line,120,fppy); 
126          for(i=0;i<3;i++)     
127         {  
128            field(i+1,Line, shqlj[i]);  /*提取行情路径*/  
129         }
130             
131         fgets(Line,120,fppy); 
132          for(i=0;i<9;i++)  
133         {         
134            field(i+1,Line, color[i]);  /*提取颜色设置*/  
135         }
136             
137               
138         fgets(Line,120,fppy); 
139         field(1,Line,hq[0]);  /*提取行情设置*/  
140         field(2,Line,pm[0]);  /*提取跑马*/  
141          
142         fgets(Line,120,fppy); 
143         field(1,Line,hqtime[0]);  /*提取行情刷新设置*/  
144          fclose(fppy);  
145                 
146         hz24(155,30,1,1,atoi(color[0]),"..证券"); /* 输出主题*/
147         hz24(254,30,1,1,atoi(color[0]),strzt); /* 输出主题*/
148         
149         /*hz24(155,30,1,1,12,"滨海证券滨海营业部客户终端"); */
150         cl=atoi(color[3]);
151         
152         for(i=0;i<LEN+1;i++)  
153         {hz24(260,83+i*42,1,1,cl,strsm[i]);  
154         
155         free(strsm[i]);
156         } /*     输出菜单说明*/ 
157            
158          cl=atoi(color[4]);
159         hz16(10,438,cl,"客服电话",2); 
160         setcolor(7);     
161         settextstyle(1,HORIZ_DIR,1);        
162           outtextxy(96,443,strt1[0]); 
163                    
164         hz16(290,438,cl,"故障报修",2); 
165         setcolor(7);
166         settextstyle(2,HORIZ_DIR,1); 
167          outtextxy(370,443,strt2[0]);  
168            
169           cl=atoi(color[6]); 
170            setcolor(7);        
171         settextstyle(3,HORIZ_DIR,1);
172         outtextxy(594,463,power);/*制作人*/
173            cl=atoi(color[7]); 
174          setcolor(cl);  
175         /*跑马灯*/
176         
177         /* hz16(284,458,cl,strts,2); 
178              settextstyle(4,HORIZ_DIR,1);
179           outtextxy(376,463,strts3); 
180             
181            hz16(410,458,cl,strts1,2);    
182             settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
183              outtextxy(500,463,strts4); 
184           */     
185           
186          /*      
187            while(1){        
188              hz16(410,458,cl,strts1,2);  
189             settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
190              outtextxy(500,463,strts4); 
191             sleep(1);
192             x=x-1; 
193              if (x<=0) x=60;
194          }
195          */
196           
197          
198          setcolor(7);      
199                     
200                
201              
202             hz16(3,458,14,"",2); 
203            prhq(0); 
204            /* 深圳不显示 2014-12-5*/
205            hz16(143,458,14,"",2);
206            prhq1(0);                      
207            
208             
209              prtime();
210            
211             i=0; hqtimesz=3;
212            cl=atoi(color[1]); /* 菜单字的颜色*/  
213             hqsz=atoi(hq[0]); /* 行情设置*/  
214           pmsz=atoi(pm[0]); /* 跑马设置*/  
215           hqtimesz=atoi(hqtime[0]); /* 行情设置*/
216 
217               g_pmx=376; 
218             new_g_pmx=g_pmx; 
219             setfillstyle(SOLID_FILL,0);/*把原来的老时间给去除*/
220              bar(280,458,650,473);
221             rectangle(638,455,638,476);
222             if (pmsz==1)
223              prpaoma(strts);
224                else
225              hz16(280,458,15,strts,2); 
226            
227         if  (hqtimesz==0) hqtimesz=1;
228            
229            prmenutxt(1); 
230           
231        for(;;){
232                    
233         i=menu(158,80,1,strxm,cl,40,hqsz,hqtimesz,strts2,strts,pmsz);  
234                    switch(i){
235                 case 0: closegraph(); exit(0); 
236                 case 1:closegraph(); exit(1);
237                 case 2:closegraph(); exit(2);
238                 case 3:closegraph(); exit(3);
239                 case 4:closegraph(); exit(4);
240                 case 5:closegraph(); exit(5);
241                 case 6:closegraph(); exit(6);
242                 
243             }
244              }
245              
246         /*  closegraph();*/
247          
248            /* free(save);*/
249     }
250 
251 


wumenu.h

  1 /*
  2 ver 2.131016 
  3 Author :吴chunyuan
  4 last:        2014-12-5 
  5 版本提示 键F1 或PAGEDOWN
  6 menu 增加hqsz 参数, 0-不更新 1-更新深圳 2-更新上海 3 -深圳上海都更新 4- 15:00后更新
  7 解决上海深圳行情更新问题: outzs 等变量char * 改为 char  outzs[ ]-20130115
  8 2013-11-13 实现跑马灯prpaoma()  
  9 2013-11-21 增加跑马灯是否滚动设置
 10 */
 11 char power[20]="Author Wuchunyuan" ;/*Author*/
 12 struct time now;/*这里的变量都是时间有关*/
 13 int g_pmx,old_g_pmx,new_g_pmx,old,new1,oldhq,newhq,oldhq1,newhq1;
 14 
 15 char ss[10],sssh[20],sssz[20]; /*输出时间 行情*/
 16 char outzs1[12];
 17 char outdq1[12] ; /* sh */
 18 char outkp1[12]; /* sh */
 19 char outzs[8];
 20 char outdq[8] ;
 21 char outkp[8];
 22 float fshzs,fszzs,shzf,szzf;
 23 char * shqlj[3]={"1111111111111111111111111111","1111111111111111111111111111"} ;
 24  FILE *fppy1; 
 25 char * Line1;
 26 char strt1[50] ;
 27 char strt2[50] ;
 28  FILE *fpsh;
 29 char *strsh;
 30  char fnamesh[40];
 31  FILE *fp1;
 32 char *str1;
 33 char fname1[30]; 
 35  FILE *fprd;
 36 char *strrd;
 39 static void forcefloat(float * p) /* 解决atof () floating point formats not linked错误*/
 40 {
 41     float f =*p;
 42     forcefloat(&f); 
 43 }
 47 int prtime()/*输出时间的函数*/
 48 {
 49  gettime(&now);
 50  new1=now.ti_sec;
 51  if(abs(new1-old)>=1)
 52   {
 53   setfillstyle(SOLID_FILL,0);/*把原来的老时间给去除*/
 54   bar(566,443,634,453);
 55   old=new1;
 56   sprintf(ss,"%02d:%02d:%02d",now.ti_hour,now.ti_min,now.ti_sec);
 57   setcolor(7);
 58       settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
 59   outtextxy(571,443,ss);
 60  if (strcmp(ss,"15:00:00")<0)  return 0;
 61       else return 1;    
 64 } 
 65 }
 66 
 67 
 68  void cut(char buf[30]) /*去掉串中非数字字符*/
 69  {
 70      int j,i;
 71      char s[30];
 72     i=0;
 74      j=0;
 75   while(buf[i] )
 76   { if  ( buf[i]=='0' || buf[i]=='1' ||buf[i]=='2'  || buf[i]=='3' ||buf[i]=='4' || buf[i]=='5' ||buf[i]=='6'  || buf[i]=='7'||buf[i]=='8' || buf[i]=='9' ||buf[i]=='.'  )
 77          s[j++]=buf[i++];  else{
 78           s[j]='\0';
 79           strcpy(buf,s);
 80         return;}
 81     }        
 82  }
 83   
 87 int foutzs1() /*上海行情*/
 88 
 89 {  
 90     unsigned int recno, headlength,reclength;
 91     /*unsigned long recnumber;*/
 92     unsigned char t1,t2,t3,t4;   
 95     /*outzs=(char *)malloc(8);
 96       outkp=(char *)malloc(8);
 97         outdq=(char *)malloc(8);*/
 98          strsh=(char *)malloc(266); /*show2003-265*/
 99            strcpy(fnamesh,shqlj[0]);
100         if((fpsh=fopen(fnamesh,"rb"))==NULL){
101         /*printf("Open File error:%s\n",fnamesh);*/
102         setfillstyle(SOLID_FILL,0);/*把原来的老行情给去除*/
103           
104         bar(22,462,80,472);
105          outtextxy(22,463,"not file");
106          
107            return -1;}
108             
109               fseek(fpsh, 4L,0);/*计算记录个数 recnumber */
110              
111             fscanf(fpsh, "%c%c%c%c", &t1,&t2,&t3,&t4);
112             /*recnumber=t1+t2*0x100+t3*0x10000+t4*0x1000000;*/
113           
114             fseek(fpsh, 8L, 0); /*计算文件头长度 headlength */
115           
116             fscanf(fpsh, "%c%c", &t1,&t2);
117                 headlength=t1+t2*0x100;
120             fseek(fpsh,10L,0); /*计算记录长度 reclength */
122              
123                fscanf(fpsh, "%c%c", &t1,&t2);
124             reclength=t1+t2*0x100;
125              
126             fseek(fpsh,headlength+reclength, 0);/*将文件指针定位到第二记录开始处*/
127                            
128             fgets(strsh, reclength+1, fpsh);/*取第二行*/
129             /*rewind(fpsh);*/
130                  strncpy(outzs,strsh+15,7);
131               
132               strncpy(outkp,strsh+23,7);
133              
134              strncpy(outdq,strsh+59,7);
135              
136              /*cut(outkp);
137              cut(outzs);
138              cut(outdq);*/
139              free(strsh);
140                fclose(fpsh);
141              return 0;
142                          
143     }
144             
145 
146 int foutzs2() /*深圳行情*/
147 
148 {  
149     unsigned int recno, headlength,reclength;
150     /*unsigned long recnumber;*/
151     unsigned char t1,t2,t3,t4;
152      
153      
154        str1=(char *)malloc(124);
155          
156      strcpy(fname1,shqlj[1]);
157     /* outzs1=(char *)malloc(12);
158         outkp1=(char *)malloc(12);
159         outdq1=(char *)malloc(12);*/
160      
161      if((fp1=fopen(fname1,"rb"))==NULL){
162     /*if((fp1=fopen("n:\\/vsat/SJSZS.DBF","rb"))==NULL){
163         /* printf("Open File error\n");*/
164          
165         setfillstyle(SOLID_FILL,0);/*把原来的老行情给去除*/
166           
167         bar(160,462,260,472);
168          outtextxy(160,463,"not file");
169            
170            return -1;}
171          
172     
173           fseek(fp1, 4L,0) ;  
174              
175         fscanf(fp1, "%c%c%c%c", &t1,&t2,&t3,&t4);
176         /*recnumber=t1+t2*0x100+t3*0x10000+t4*0x1000000;*/
177         fseek(fp1, 8L, 0);/*计算文件头长度 headlength*/ 
178          fscanf(fp1, "%c%c", &t1,&t2);
179           headlength=t1+t2*0x100;
180         fseek(fp1,10L,0); /*计算记录长度 reclength*/ 
181          fscanf(fp1, "%c%c", &t1,&t2);
182         reclength=t1+t2*0x100;
183         fseek(fp1,headlength, 0);/*将文件指针定位到第一记录开始处*/
184         
185          fgets(str1, reclength+1, fp1); 
186         /* rewind(fp1);*/
187                   strncpy(outzs1,str1+40,8);
188                     
189                     strncpy(outkp1,str1+49,8);
190                       strncpy(outdq1,str1+84,8);
191                     /*cut(outdq1);
192                     cut(outzs1); 
193                      cut(outkp1); */
194                     free(str1);
195                       fclose(fp1); 
196                       return 0;    
197     }
198             
199 void prhq(int n)/*输出上海实时行情的函数*/
200 {
201  gettime(&now);
202  newhq=now.ti_sec;
203     
204  if(abs(newhq-oldhq)>=n)/*刷新间隔n秒*/
205   {
206   oldhq=newhq;
207       if (foutzs1()==0) {
208      
209             if (strcmp(outdq,outzs)>0) 
210               setcolor(4); else 
211                setcolor(2);
212         
213         fshzs=atof(outdq)-atof(outzs); 
214          shzf=(fshzs/atof(outzs))*100; 
215          sprintf(sssh,"%4.2f%s",shzf,"%");
216         setfillstyle(SOLID_FILL,0);/*把原来的老行情给去除*/
217           bar(22,462,82,472);
218          bar(88,462,136,472);
219          outtextxy(22,463,outdq);
220         outtextxy(89,463,sssh);}
221         setcolor(7);
222         /*free(outzs);
223              free(outkp);
224           free(outdq); */ 
225         } ;
226      
227 }
228 
229 
230 
231 void prhq1(int n)/*输出实时深圳行情的函数*/
232 {
233  gettime(&now);
234  newhq1=now.ti_sec;
235  if(abs(newhq1-oldhq1)>=n)/*刷新间隔n秒*/
236   {      
237   oldhq1=newhq1;
238       if (foutzs2()==0) {
239     
240          
241            setfillstyle(SOLID_FILL,0);/*把原来的老行情给去除*/
242            bar(162,462,222,472);
243           bar(230,462,278,472);
244           if (strcmp(outdq1,outzs1)==0) 
245           setcolor(7);
246            if (strcmp(outdq1,outzs1)>0) 
247           setcolor(4);
248               if (strcmp(outdq1,outzs1)<0) 
249           setcolor(2);
250         fszzs=atof(outdq1)-atof(outzs1); 
251          szzf=(fszzs/atof(outzs1))*100; 
252         sprintf(sssz,"%4.2f%s",szzf,"%");
253         outtextxy(162,463,outdq1);
254         outtextxy(234,463,sssz);
255             /* free(outzs1);
256                    free(outkp1);
257                    free(outdq1);*/
258             setcolor(7);
259     } ;
260 }
261 }

266 int counttab(char tab,char s[120]) /*计算字符串中分符数量*/
267 {
268     int i,num;
269     char c;
270     
271      
272      i=0;num=0;
273     while((c=s[i++])!='\0'){
274         
275         if (c==tab) num++;
276     }
277     
278      return num;
279      
280 }
281 

285 void getoneline(char Line[120])  /*读文本1行*/
286     {
287         int i;
288         i=0;
289         while(Line[i]!='\n') i++;
290         Line[i]='\0';
291     }
292 

296 void field(int n,char buf[120],char s[30])
297  
298 {
299   int i,j;
300   i=0;
301   while(n>1 && buf[i]!='\n'  &&buf[i]!='\t' && buf[i]!=0){
302     if(buf[i]==',' || buf[i]=='|') n--;
303     i++;
304   }
305   j=0;
306   while(buf[i] && buf[i]!=',' && buf[i]!='\t' && buf[i]!='|'  && buf[i]!='\n') s[j++]=buf[i++];
307   s[j]='\0';   
309 }
 
313 void hz16(int x,int y,int color,char *s,int bit)
314 {
315     FILE *fp;
316     char buffer[32];/*buffer用来存储一个汉字 */ 
317     char q[2];
318     register m,n,i,j,k;
319     unsigned char qh,wh; 
320     unsigned long offset;  
321     int ROW,COL;
322     /*#define ROW 1/*纵坐标放大倍数*
323 #define COL 2/*横坐标放大倍数*/  
324     
325     ROW=1;
326     COL=1;
327      
328     if ((fp=fopen("./HZK16","rb"))==NULL){
329         printf("Can't open hzk16\n");
330         return;
331     }
332 
333        
334     while(*s)
335     {
336      qh=*(s)-0xa0;/*汉字区位码 */
337      wh=*(s+1)-0xa0;
338         if( qh>=1 && qh<=0x5e&& qh!=0x08) {
339     offset=(94*(qh-1)+(wh-1))*32l ; /*计算该汉字在字库中偏移量 */
340      fseek(fp,offset,SEEK_SET); 
341      fread(buffer,32,1,fp);/*取出汉字32字节的点阵字模存入buffer中(一个汉字)*/ 
342      for (i=0;i<16;i++) /*将32位字节的点阵按位在屏幕上打印出来(1:打印,0:不打印),显示汉字 */
343      for(n=0;n<ROW;n++) 
344         for(j=0;j<2;j++) 
345          for(k=0;k<8;k++) 
346            for(m=0;m<COL;m++) 
347             if (((buffer[i*2+j]>>(7-k))&0x1)!=NULL) 
348              putpixel(x+8*j*COL+k*COL+m,y+i*ROW+n,color); 
349              s+=2; /*因为一个汉字内码占用两个字节,所以s必须加2 */
350               x+=18;  /*字间隔*/
351           }
352         
353         else{ 
354     moveto(x,y);
355     *q=*s; *(q+1)='\0';
356      settextstyle(DEFAULT_FONT,HORIZ_DIR,bit);
357     setcolor(color);
358             if(bit==1){
359               outtextxy(x,y+5,q);
360              x+=10;    
361             }
362             if(bit==2){
363              outtextxy(x,y+1,q);
364                  x+=16;
365             }
366             s++;
367             settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
368          }
369      }     
370          
371          fclose(fp);
372  }
373  
374  
375  void prpaoma(char ss[250])/*跑马*/
376 {
377        /*   char outss[150]; 
378          int sslen,fontss;
379               sslen=strlen(ss);    
380              fontss=sslen/2-g_pmx/20 ;
381            strncpy(outss,ss,fontss);*/
382          
383            /*  hz16(410,458,cl,strts1,2);  
384             settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
385                outtextxy(500,463,strts4);*/
386             setfillstyle(SOLID_FILL,0);/*把原来的老时间给去除*/
387             bar(280,458,650,473);
388          
389         /*sprintf(ss,"13822527544");
390         sprintf(outss,"%03d-%03d",g_pmx,sslen);
391         outtextxy(500,63,outss);
392          hz16(410,458,cl,strts1,2); /*跑马灯*/
393         
394         settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
395          if (new_g_pmx>=379)   {
396         hz16(280,458,15,ss,2);
397            delay(29800);
398         }else
399         hz16(280+new_g_pmx,458,15,ss,2);
400          
401           settextstyle(DEFAULT_FONT,HORIZ_DIR,1);    
402         
403           rectangle(638,455,638,476);
404          delay(9800);         
406         /*sleep(1);*/
407 }

411  void init1()/*按F1时*/
412 { 
413     
414 setfillstyle(SOLID_FILL,0);/*把原来的给去除*/
415 bar(280,458,650,473);
416  
417 setcolor(7);
418 outtextxy(281,463,"Author:WuChunYuan ver2.131121");/*制作人*/      
419              hz16(143,458,14,"",2);
420             hz16(3,458,14,"",2); 
421   rectangle(1,25,638,476); /*整个画面*/
422     
423     rectangle(1,455,638,455); /* 第二层*/
424       
425 rectangle(1,455,140,476);/* 上海指数*/
426     
427 rectangle(1,455,279,476); /* 深圳指数*/
428  
429 rectangle(1,455,638,476);/*跑马灯,后显示制作人*/
430     
431 setfillstyle(SOLID_FILL,0);/* F1给去除*/
432 bar(260,45,630,410);
433     
434 setfillstyle(SOLID_FILL,0);/*把主题去除*/
435 bar(120,26,610,70);
436 
437 setfillstyle(SOLID_FILL,0);/*把 给去除*/
438 bar(120,380,635,420);
439         
440 }

444 void reader()
445 {
446  
447     int i;
448      
449      
450     unsigned char t1,t2,t3,t4;
451     
452     init1();
453      
454     if ((fprd=fopen("./wucym.txt","r"))==NULL){
455         printf("Can't open \n");
456         return;
457     }
458      
459      strrd=(char *)malloc(120000); 
460       fseek(fprd,0L,0);
461       for (i=1;i<17;i++){
462       fgets(strrd,120,fprd); 
463           
464        hz16(260,10+i*24,3,strrd,2);
465           
466       }    
468            free(strrd);
469          fclose(fprd);
470 }    

475 void hz24(int x0,int y0,int tx,int ty,int color,char *str)
476 {
477     FILE *fp;
478     int j,k,a,b;
479     long int num_bytes;
480     char qm,wm;
481     char q[2];
482     int t;
483     int bit=128;
484     int x,y,m;
485     char ch;
486     char *data;
487 
488     if ((fp=fopen("./HZK24K","rb"))==NULL){
489         printf("Can't open hzk24\n");
490         return;
491     }
492      
493     x=x0;
494      y=y0;
495     while(*str)
496     {k=-3;x=x+1;
497 
498      qm=*str-0xa0; wm= *(str+1)-0xa0;
499       if( qm>=1 && qm<=0x5e)  /* && wm>=0x5e*/
500      {
501          data=(char *)malloc(72);
502          num_bytes=((long)((qm)-16)*94+(wm)-1)*72;
503 
504         fseek(fp,num_bytes,SEEK_SET);
505         fgets(data,72,fp);
506 
507         do{
508             k=k+3;
509 
510         for(t=0;t<tx;t++){
511              for(a=0;a<3;a++,k=k+1){
512                  for(j=0;j<8;j++){
513                             data[k]=data[k]&255;
514                           ch=data[k]&(char)bit;
515                          for(b=0;b<ty;b++){
516                              if (ch) putpixel(x,y,color);
517                              y++;
518                          bit>>=1;
519                      }
520                          }
521                      bit=0x80;
522                  }
523                  x=x+1;y=y0;k=k-3;}
524              }while(k<69);
525              str+=2; 
526               free(data);
527              }
528         else{ 
529     moveto(x,y);
530     *q=*str; *(q+1)='\0';
531     setcolor(color);
532     settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
533     outtextxy(x,y+5,q);
534     x+=16;str++;
535     settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
536          }
537          }      
540      fclose(fp);
541 
542  }
 
547  void prver(int n)/*输出版本号*/
548 {
549 setfillstyle(SOLID_FILL,0);/*把原来的给去除*/    
550 bar(80,400,620,430);

553     if (n==1){        
556         hz16(180,405,3,"Ver2.1412051 吴春源编写,SVN:",1);             
558     }
559      if (n==2)
560      {  
561         hz16(152,415,3,"最新编译时间:20141205,吴春源编写",2);    
562      }
563 }

567  void boxb(int sx,int sy,int ex,int ey,int color,int style)
568  {
569      setcolor(color);
570      line(sx,sy,ex,sy);
571       line(ex,sy,ex,ey);
572       line(ex,ey,sx,ey);
573       line(sx,ey,sx,sy);
574      setfillstyle(style,color);
575      floodfill(sx+1,sy+1,color);
576  }
577 
578  void butt2(x,y,c,k,str,cailenth,color,w)
579  int x,y,c,k,cailenth,color,w;
580  char *str;
581  {int ex;
582      int ey;
583      int *p,*p1;
584      if(w<40)w=40;
585      ey=y+w;
586      ex=x+cailenth;
587      boxb(x,y,ex,ey,7,1);
588      boxb(x+5,y+3,ex-4,ey-4,7,1);
589      boxb(x+10,y+7,ex-9,ey-10,c,1);
590      setcolor(0);
591      rectangle(x+5,y+3,ex-4,ey-4);
592      setcolor(15);/*15*/
593      setlinestyle(0,0,1);
594      rectangle(x+8,y+6,ex-7,ey-8);
595      line(x+5,y+3,x+8,y+6);
596      line(x+5,ey-4,x+8,ey-8);
597      line(ex-4,ey-4,ex-7,ey-8);
598      line(ex-4,y+5,ex-7,y+6);
599      if (*str<0&&*str>-96)
600          hz24(x+6,y+9,1,1,color,str);
601      else
602          outtextxy(x+cailenth/3,y+9,str);
603      if(k!=1){
604          p=(int *) malloc(imagesize(x+5,y+3,ex-4,ey-4));
605          getimage(x+5,y+3,ex-4,ey-4,p);
606           p1=(int *) malloc(imagesize(x+7,y+6,ex-8,ey-7));
607          getimage(x+7,y+6,ex-8,ey-7,p1);
608          putimage(x+5,y+3,p,XOR_PUT);
609           putimage(x+7,y+6,p1,COPY_PUT);
610          delay(350);
611          putimage(x+5,y+2,p,COPY_PUT);
612            
613          free(p); free(p1);}
614            }
615 
616          
617 void prmenutxt(int n)
618 {     
620       int i ;    
623       Line1=(char *)malloc(1000); /*值不够大客户端会出现死机*/
624         
625         if((fppy1=fopen("./WuMtxt.cfg","rb"))==NULL){
626            printf("not find file WuMtxt.cfg ,QQ:41850709 \n");
627           exit(1);} 
628          
629           fseek(fppy1,0L,0);
630         
631         for(i=0;i<n;i++)  
632         fgets(Line1,120,fppy1);
633         
634         field(1,Line1,strt1);  /*提取说明1*/ 
635         field(2,Line1,strt2);  /*提取说明1*/ 
636          setfillstyle(SOLID_FILL,0); 
637         bar(10,380,630,400);
638         bar(10,400,630,430);        
642         /*把原来的给去除       SOLID_FILL 1 EMPTY_FILL 0 以背景颜色填充 */         
645             hz16(200,380,4,strt1,2); 
646          hz16(120,405,4,strt2,2); 
647         free(Line1);
648         fclose(fppy1);          
651     }

656 int menu(int x0,int y0,int n,char **str,int color,int w,int hq,int hqtimesz,char servts[50],char pmd[150],int pmsz1)
657          {
658              int ifhq,i,x,y,m1,m0=1;
659              int ex,ey,k,j,pmi;
660              union{
661                  int i;
662                  char ch[2];
663              }c;
664              x=x0;y=y0;
665               
666                  for(k=0;str[k]!=NULL;k++){
667                  m1=strlen(str[k])/2;
668                  if(m1>m0) m0=m1;}
669                     
670                       m0=m0*26+14;
671 
672                  for(k=0;str[k]!=NULL;k++)
673                    if(n==0)
674                      butt2(x+k*m0,y,7,1,str[k],m0,color,w);
675                   else
676                      butt2(x,y+k*(w+1),7,1,str[k],m0,color,w);
677                  
678                   
679                   if(n==0&&m0*k+x-k>639){
680                      hz24(100,360,1,1,12,"menu item  too many");
681                      return -1;}
682                      
683                      j=i=0;c.i=97;
684                      
685                for(;c.ch[1]!=28;){ /* 28=1c 回车*/
686                          if (n==0){
687                              butt2(x+j*m0,y,7,1,str[j],m0,color,w);
688                              butt2(x+i*m0,y,8,1,str[i],m0,color,w);
689                          }
690                          else {
691                               butt2(x,y+j*(w+1),7,1,str[j],m0,color,w);
692                               butt2(x,y+i*(w+1),8,1,str[i],m0,color,w);
693                          } j=i; 
694                          
695                            
696                           
697                           while(!kbhit()) /* 输出时间行情*/  /*功 能及返回值: 检查当前是否有键盘输入,若有则返回一个非0值,否则返回0*/
698                           {
699                               /* qh=1-只更新深圳 行情  2 -只更新上海  3-两市场行情都更新  4- 15:00后更新 */
700                              
701                              
702                              new_g_pmx=new_g_pmx-1;
703                              old_g_pmx=new_g_pmx;
704                               if(pmsz1==1)
705                               prpaoma(pmd);
706                              if (new_g_pmx<=0 ) new_g_pmx=380;
707                               
708                             ifhq=prtime();
709                             if (hq==1) 
710                              prhq1(hqtimesz); 
711                             if (hq==2) 
712                              prhq(hqtimesz); 
713                             if (hq==3) {
714                             prhq1(hqtimesz); 
715                                 prhq(hqtimesz); 
716                                }
717                               
718                               if (hq==4 && ifhq==1) {
719                               prhq1(hqtimesz);  
720                                 prhq(hqtimesz); 
721                                }
722                               
723                           }
724                                      
725                           
726                           /*
727                           
728                           int bioskey(int cmd); 
729                                                             当cmd为1时,bioskey()检测是否有键按下。没有键按下时返回0;有键按下时返回按键码( 
730                                                     任何按键码都不为0),但此时并不将检测到的按键码从键盘缓冲队列中清除。 是非阻塞参数。
731                                                             当cmd为0时,bioskey()返回键盘缓冲队列中的按键码,并将此按键码从键盘缓冲队列中清 
732                                                        除。如果键盘缓冲队列为空,则一直等到有键按下,才将得到的按键码返回。是阻塞调用。
733 
734                           */
735                           c.i=bioskey(0); 
736                                
737                                   switch(c.ch[1]){
738                              case 75:  /*左箭头*/
739                                
740                                prver(1);  
741                              hz16(450,405,3,servts,1); 
742                               
743                              if(n==0) i--; break;
744                              case 77:   /*右箭头*/
745                                     
746                              if(n==0) i++; break;
747                              case 72:  /*上键*/
748                                      
749                                if(n!=0) i--; 
750                                 if(i>=0) 
751                                 prmenutxt(i+1);
752                                  
753                                 break;
754                              
755                              case 80:  /*下键*/
756                               
757                              if(n!=0) i++; 
758                               if(i<6)  
759                               prmenutxt(i+1);
760                               
761                              break;
762                              
763                              case 1:return 0;
764                              
765                               case 81: /*PageDown*/
766                               
767                                prver(1);
768                               
769                                      hz16(450,405,3,servts,1); 
770                                break;
771                                
772                               case 59: /*F1*/
773                                 
774                                  reader();
775                                  prver(2);
776                               break;
777                              
778                               
779                              default: prmenutxt(i+1); break;}
780                              
781                              
782                               if(i<0) i=0;
783                               if(j<0) j=0;
784                               if(i>=k) i=k-1;}  /* for /* 28=1c 回车  -end */
785                               
786                               outtextxy(230,463,"1");   
787                                
788                                    if(n==0) 
789                                 butt2(x+i*m0,y,7,0,str[i],m0,color,w);
790                              
791                                     else
792                                    butt2(x,y+(w+1)*i,7,0,str[i],m0,color,w);
793                               outtextxy(230,469,"2");  
794                               
795                                 return i+1;
796                              
797                              
798                          }

 

  

 

    

推荐阅读