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

📄 index.c

📁 C语言编写的仿视窗多程序演示系统
💻 C
📖 第 1 页 / 共 3 页
字号:
/* WIN-TC BGI 图形编程模板 */

#include <Conio.h>
#include <graphics.h>
#include <stdio.h>
#include <dos.h>
#include <stdlib.h>
#include "main1.c"
#include "main2.c"
#include "main3.c"
#include "main4.c"
#include "main5.c"
#include "main6.c"



#define closegr closegraph


#define ALT_S 31

int MaxX,MaxY;

void initgr(void) /* BGI初始化 */
{
    int gd=DETECT,gm=0; /* 和gd=VGA,gm=VGAHI是同样效果 */
    registerbgidriver(EGAVGA_driver);/* 注册BGI驱动后可以不需要.BGI文件的支持运行 */
    initgraph(&gd,&gm,"");
}

void far loadbmp(int y1,int width,int highth,char far *fname)
{
  char Get_txt[1000];
  struct BIT_MAP_FILE_HEADER
  {
    char bfType[2];
    long int bfSize;
    int bfReserved1;
    int bfReserved2;
    long int bfOffBits;
  };
  FILE *fp;
  char far* ptr=(char far*) 0xA0000000L;
  char color[16]={0,4,2,6,1,5,3,8,7,12,10,14,9,13,11,15};
  int i,x,y;
  int bmplength,bmpwidth;
  struct BIT_MAP_FILE_HEADER head;
  char temp;
  if ((fp=fopen(fname,"rb"))==NULL) return;
  fread(&head,sizeof(head),1,fp);
  fseek(fp,18,SEEK_SET);
  fread(&bmplength,sizeof(int),1,fp);
  fseek(fp,22,SEEK_SET);
  fread(&bmpwidth,sizeof(int),1,fp);
  ptr--;
  outportb(0x3ce,1);
  outportb(0x3cf,0xff);
  outportb(0x3ce,3);
  outportb(0x3cf,0x10);
  if(width>bmplength) width=bmplength;
  if(highth>bmpwidth) highth=bmpwidth;
  for(y=0;y<y1;y++)
    for(i=0;i<320;i++){
      if(((i % 4)==0)) ptr++;
      if(i<(width+1)/2){
    temp=color[0];
    outportb(0x3ce,0);
    outportb(0x3cf,temp);
    outportb(0x3ce,8);
    outportb(0x3cf,0x80>>((i*2)%8));
    (*ptr) &= 0xff;
    temp=color[0];
    outportb(0x3ce,0);
    outportb(0x3cf,temp);
    outportb(0x3ce,8);
    outportb(0x3cf,0x40>>((i*2)%8));
    (*ptr) &= 0xff;
      }
    }
  for(y=0;y<highth;y++)
  {
    fseek(fp,-((head.bfSize-(long)head.bfOffBits)/bmpwidth)*(long)(y+1),SEEK_END);
    fread(Get_txt,(bmplength+1)/2, 1, fp);
    for(i=0;i<320;i++){
      if(((i % 4)==0)) ptr++;
      if(i<(width+1)/2){
    temp=color[(Get_txt[i]&0xf0)>>4];
    outportb(0x3ce,0);
    outportb(0x3cf,temp);
    outportb(0x3ce,8);
    outportb(0x3cf,0x80>>((i*2)%8));
    (*ptr) &= 0xff+y1;
    temp=color[Get_txt[i] &0x0f];
    outportb(0x3ce,0);
    outportb(0x3cf,temp);
    outportb(0x3ce,8);
    outportb(0x3cf,0x40>>((i*2)%8));
    (*ptr) &= 0xff+y1;
      }
    }
  }
  outportb(0x3ce,0);
  outportb(0x3cf,0);
  outportb(0x3ce,1);
  outportb(0x3cf,0);
  outportb(0x3ce,3);
  outportb(0x3cf,0);
  outportb(0x3ce,8);
  outportb(0x3cf,0xff);
  fclose(fp);
}
/*
void clrkey()
{
    union REGS r;
    r.h.ah=0x0c;
    intdos(&r,&r);
}
*/

/*
int Contrkey()
{
    int prskey;
    while(bioskey(1)==0);
    prskey=bioskey(0);
    prskey=prskey&0xff?prskey&0xff:prskey>>8;

    return(prskey);
}
*/


void Draw_down()
{

    setfillstyle(SOLID_FILL,BLUE);
    bar(0,0,MaxX,MaxY-30);
    setfillstyle(SOLID_FILL,LIGHTGRAY);
    bar(0,MaxY-50,MaxX,MaxY-30);
    loadbmp(0,640,430-1,"tempback.bmp");
    setcolor(WHITE);
    line(0,MaxY-50-1,MaxX,MaxY-50-1);
    line(0,MaxY-50-1,0,MaxY-30);
    line(0,MaxY-50-1+2,MaxX,MaxY-50-1+2);
    setcolor(BLACK);
    line(0,MaxY-50-1+1,MaxX,MaxY-50-1+1);

}

void Up_mainmenu(int x_start,int y_start,int ww,int hh,int deep)
{
  int i;

    for (i=1;i<=deep;i++)
    {
        setcolor(WHITE);
        line(x_start+i,y_start+i,x_start+ww-i,y_start+i);/*横*/
        line(x_start+i,y_start+i,x_start+i,y_start+hh-i);/*竖*/
        setcolor(DARKGRAY);
        line(x_start+ww-i,y_start+hh-i,x_start+i,y_start+hh-i);/*横*/
        line(x_start+ww-i,y_start+hh-i,x_start+ww-i,y_start+i);
    }
}

void Down_mainmenu(int x_start,int y_start,int ww,int hh,int deep)
{
    int i;

    for (i=1;i<=deep;i++)
    {
        setcolor(DARKGRAY);
        line(x_start+i,y_start+i,x_start+ww-i,y_start+i);/*横*/
        line(x_start+i,y_start+i,x_start+i,y_start+hh-i);/*竖*/
        setcolor(WHITE);
        line(x_start+ww-i,y_start+hh-i,x_start+i,y_start+hh-i);/*横*/
        line(x_start+ww-i,y_start+hh-i,x_start+ww-i,y_start+i);
    }
}

void Draw_go_Up()
{
    setfillstyle(SOLID_FILL,LIGHTGRAY);
    bar(0+1,MaxY-50+1+1,50-1,MaxY-50+1+20-1);
    Up_mainmenu(0,MaxY-50+1,50,20,1);
    PrintTextxy(0+1,MaxY-50+1+1,"GO!",YELLOW);
    PrintTextxy(0+1+1,MaxY-50+1+1+1,"GO!",LIGHTBLUE);

}

void Draw_go_Down()
{
    setfillstyle(SOLID_FILL,LIGHTGRAY);
    bar(0+1,MaxY-50+1+1,50-1,MaxY-50+1+20-1);
    Down_mainmenu(0,MaxY-50+1,50,20,1);
    PrintTextxy(0+1+1,MaxY-50+1+1+1,"GO!",YELLOW);
    PrintTextxy(0+1+1+1,MaxY-50+1+1+1+1,"GO!",LIGHTBLUE);

}

void Draw_mainmenu(int x_start,int y_start)
{
    int jg=50;
    setfillstyle(SOLID_FILL,LIGHTGRAY);
    bar(x_start+1+21,y_start+1,x_start+170-1,y_start+300-1);
    setfillstyle(SOLID_FILL,BLACK);
    bar(x_start+1,y_start+1,x_start+169,y_start+300-1);
    loadbmp(y_start+2,170,300,"left1.bmp");
    Up_mainmenu(x_start,y_start,170,300,1);
    PrintTextxy(x_start+70,MaxY-72,"退出",BLACK);
    PrintTextxy(x_start+70,MaxY-72-jg-5,"关于",BLACK);
    PrintTextxy(x_start+70,MaxY-72-jg-45,"帮助",BLACK);
    PrintTextxy(x_start+70,MaxY-72-jg-90,"说明 ",BLACK);
    PrintTextxy(x_start+70,MaxY-72-jg-135,"程序",BLACK);

}


void Draw_promenu(int x_start,int y_start)/* 190*300 */
{
    setfillstyle(SOLID_FILL,LIGHTGRAY);
    bar(x_start+1,y_start+1,x_start+190-1,y_start+255-1);
    setfillstyle(SOLID_FILL,BLACK);
    bar(x_start+1,y_start+1,x_start+190-1,y_start+255-1);
    loadbmp(y_start,190,255,"promenu.bmp");
    Up_mainmenu(x_start,y_start,190,255,1);
}


int barset(int yy)
{
    setfillstyle(SOLID_FILL,BLUE);
    loadbmp(MaxY-yy,165,22,"sbar.bmp");
}

int barredo(int yy)
{
    setfillstyle(SOLID_FILL,BLUE);
    loadbmp(MaxY-yy,165,22,"rbar.bmp");
}

void xorbar(void *bufferbarl,int n1)
{
    int hh=16,jg=22,x=150,y=50,i;
    i=(7-n1);
    putimage(x+5,y+jg*i+hh*(i-1),bufferbarl,XOR_PUT);
}

void loadpro(char *str)
{
    int xx=170,yy=210,i=0;
    char num[4]="0";
    void *buffertemp;
    if ((fp=fopen("load.dat","rb"))==NULL) return;
    buffertemp=malloc(imagesize(0+1,0+1,289-1,86-1-1));
    fread(buffertemp,imagesize(0+1,0+1,289-1,86-1-1),1,fp);
    putimage(0+160,180,buffertemp,COPY_PUT);
    fclose(fp);

⌨️ 快捷键说明

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