cắt và ghép code trong C

Hoang_Nguyen

Youtube Master Race
em có đoạn code về giao diện của C đã hoàn tất.bác nào giúp em cắt code từ bài ->
PHP:
http://gamevn.com/showthread.php?t=237628
ghép vào đoạn code giao diện trên đc ko.để khi thực hiện các lệnh chỉ việc thao tác bằng các nút thì lệnh sẽ thực hiện
Mã:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <string.h>
#include <ctype.h>

#define TRUE 1
#define FALSE 0
#define M 30
#define Down  80
#define Up 72
#define Enter 13
#define BKCOLOR RED

//---------------------------------------------------------------------------
int done=FALSE;
void Gioithieu();
void CmdButton(int x1,int y1,int x2,int y2,int lightcolor,
			 int darkcolor,char *name,int textcolor,int bkcolor);
void Window(int x1,int y1,int x2,int y2,int deep,
				int lightcolor,int darkcolor,int backcolor );
void DoulbLine(int x1,int y1,int x2,int y2,int color1,int color2);
void ClearWin(int x1,int y1,int x2,int y2,int color);
void SelectBox(int i);
void DeSelectBox(int i);
void Gioithieu()
 {
  int x=getmaxx();
  int y=getmaxy();
  ClearWin(x/3-1,y/3+33,x,y,0);
  setcolor(15);
  outtextxy(x/2,y/2,"phan gioi thieu");
  line(x/3-1,y/2-37,x,y/2-37);
  getch();
 }
//***************************************************************************
/*Ham tao tu dien*/
int l=0;
void MakeDictionary()
 {
  int x=getmaxx();
  int y=getmaxy();
  ClearWin(x/3-1,y/3+33,x,y,0);
  setcolor(15);
  rectangle(x/3-1,y/2-37,x,y/2-18);
  outtextxy(x/2+80,y/2-30,"ADD ");
 }

//***************************************************************************
void FindWord()
 {
  int x=getmaxx();
  int y=getmaxy();
  setcolor(15);
  ClearWin(x/3-1,y/3+33,x,y,0);
  rectangle(x/3-1,y/2-37,x,y/2-18);
  outtextxy(x/2+80,y/2-30,"FIND");
  outtextxy(x/3,y/2-11,"Test nhap tu:");
  fflush(stdin);
  gotoxy(x/14-9,y/59+7);
  return;
 }
//***************************************************************************
void CmdButton(int x1,int y1,int x2,int y2,int lightcolor,
			 int darkcolor,char *name,int textcolor,int bkcolor)
 {
  setcolor(lightcolor);
  rectangle(x1,y1,x2,y2);
  setfillstyle(1,bkcolor);
  floodfill((x1+x2)/2,(y1+y2)/2,lightcolor);
  setcolor(darkcolor);
  line(x2,y2,x1,y2);
  line(x2,y2,x2,y1);
  settextjustify(CENTER_TEXT,CENTER_TEXT);
  setcolor(textcolor);
  outtextxy((x1+x2)/2,(y1+y2)/2,name);
  settextjustify(LEFT_TEXT,TOP_TEXT);
 }
//***************************************************************************
void DoulbLine(int x1,int y1,int x2,int y2,int color1,int color2)
 {
  setcolor(color1);
  line(x1,y1,x2,y2);
  setcolor(color2);
  if(y1==y2)line(x1,y1+1,x2,y2+1);
  else if(x1==x2)line(x1+1,y1,x2+1,y2);
 }
//***************************************************************************
void SelectBox(int i)
 {
  int x=getmaxx(),y=getmaxy();
	 setcolor(1);
	 setlinestyle(DASHED_LINE,1,1);
	 rectangle(x/20-18,y-156+21*(i-1),x/3-22,y-142+21*(i-1));
	 setlinestyle(SOLID_LINE,1,1);
 }
//***************************************************************************
void DeSelectBox(int i)
 {
  int x=getmaxx(),y=getmaxy();
	 setcolor(7);
	 rectangle(x/20-18,y-156+21*(i-1),x/3-22,y-142+21*(i-1));
 }

//***************************************************************************
void ClearWin(int x1,int y1,int x2,int y2,int color)
 {
	 setfillstyle(1,color);
	 bar(x1,y1,x2,y2);
 }
//***************************************************************************
void Exit()
 {
  int x=getmaxx(),y=getmaxy();
  char ch;
	 ClearWin(x/3-1,y/3+33,x,y,0);
	 setcolor(YELLOW);
	 outtextxy(x/2,y/3+45,"Ban co muon thoat khong?");
	 outtextxy(x/2,y/3+65,"      Y/N ?");
	 while(ch!='Y'&&ch!='N'&&ch!=13&&ch!=27) ch=toupper(getch());
	 if(ch=='Y'||ch==13)done=TRUE;
	 else  ClearWin(x/3+3,y/3+33,x-3,y,0);
 }
//***************************************************************************
void Graphics()
 {
  /* Yeu cau tu dong phat hien */
  int gdriver=DETECT, gmode, errorcode;

  /*Khoi tao do hoa va bien dia phuong*/
  initgraph(&gdriver,&gmode,"");

  /*Doc ket qua khoi tao*/
  errorcode=graphresult();

  if (errorcode!=grOk)/* Co loi do hoa*/
   {
	printf(" Loi do hoa : %s\n",grapherrormsg(errorcode));
	printf("An phim bat ky de ket thuc");
	getch();
	exit(1);
   }

  int x=getmaxx();
  int y=getmaxy();     /* Khai bao gia tri cua x va y */
  setcolor(getmaxcolor());
  setfillstyle(1,1);
  bar(0,0,x,y/4);
  outtextxy(x/3,y/24,"DAI HOC QUOC GIA TP HO CHI MINH");
  outtextxy(x/3-30,y/24+15,"DAI HOC CONG NGHE THONG TIN");
  outtextxy(x/3-20,y/24+30,"-*************************************-");
  outtextxy(x/3-10,y/24+45,"MON : CAU TRUC DU LIEU VA GIAI THUAT");
  outtextxy(x/4,y/24+60," TEN DE TAI :VIET CHUONG TRINH CAI DAT BANG BAM");
  outtextxy(x/2-60,y/24+75,"NHOM THUC HIEN :2 ");
  outtextxy(x/3,y/24+90,"GIAO VIEN HUONG DAN :NGUYEN TUAN ANH ");
  int r = 60;
  setcolor(getmaxcolor());
  setfillstyle(1,10);
  fillellipse(x/10+15,y/10+15,r,(r/2)+2);
  ellipse(x/10+15,y/10+15,100,200,r,r/2);
  DoulbLine(0,y/4,x,y/4,WHITE,DARKGRAY);
  setfillstyle(1,2);
/*Ve chu T*/
  bar(x/17-5,y/10,x/17+22,y/10+6);
  bar(x/17+5,y/11+10,x/17+12,y/11+35);
  setfillstyle(1,4);
/*Ve chu D*/
  bar(x/10+2,y/11+4+1/2,x/10+9,y/11+35+1/2);
  bar(x/10+2,y/11+4+1/2,x/10+19,y/11+10+1/2);
  bar(x/10+20,y/11+5,x/10+23,y/11+11);
  bar(x/10+24,y/11+7,x/10+27,y/11+13);
  bar(x/10+27,y/11+9+3/4,x/10+31,y/11+16);
  bar(x/10+29,y/11+13,x/10+33,y/11+28);
  bar(x/10+27,y/7+1+3/4,x/10+31,y/7+7);
  bar(x/10+24,y/7+4+1/2,x/10+27,y/7+10+1/2);
  bar(x/10+20,y/7+6+1/2,x/10+23,y/7+10+1/2);
  bar(x/10+20,y/7+6+1/4,x/10+20-15,y/7+10+1/2);
  setfillstyle(1,13);
/*Ve chu C*/
  bar(x/10+37,y/7+5,x/10+37+5,y/7+4-20);
  bar(x/10+39,y/7+6,x/10+39+5,y/7+9);
  bar(x/10+39,y/7+4-20,x/10+39+5,y/7+4-23);
  bar(x/10+41,y/7+4-22,x/10+41+5,y/7+4-25);
  bar(x/10+41,y/7+7,x/10+41+5,y/7+10);
  bar(x/10+46,y/7+7,x/10+46+12,y/7+10);
  bar(x/10+46,y/7+4-22,x/10+46+12,y/7+4-25);
  bar(x/10+58,y/7+4-24,x/10+58+3,y/7+4-21);
  bar(x/10+58,y/7+8-2,x/10+58+3,y/7+11-2);
  bar(x/10+60,y/7+4-22,x/10+60+3,y/7+4-19);
  bar(x/10+60,y/7+8-4,x/10+60+3,y/7+11-4);
  setfillstyle(1,2);
  bar(x/4+50,y/4+1,x/4-200,y);
  DoulbLine(x/3-3,y/4+1,x/3-3,y,WHITE,DARKGRAY);
  setcolor(4);
  outtextxy(x/20-15,y/4+20,"THANH VIEN THUC HIEN:");
  outtextxy(x/20-25,y/4+35,"1 - ");
  outtextxy(x/20-25,y/4+50,"2 - ");
  outtextxy(x/20-25,y/4+65,"3 - ");
  outtextxy(x/20-25,y/4+80,"4 - ");
  outtextxy(x/20-25,y/4+95,"5 - ");
  DoulbLine(x/20-25,y/4+170,x/3-25,y/4+170,WHITE,DARKGRAY);
  DoulbLine(x/20-25,y/4+172,x/3-25,y/4+172,WHITE,DARKGRAY);
  setcolor(0);
  outtextxy(x/20-10,y/4+185,"       MENU");
  DoulbLine(x/20-10,y/4+315,x/3-40,y/4+315,WHITE,DARKGRAY);
  DoulbLine(x/20-10,y/4+317,x/3-40,y/4+317,WHITE,DARKGRAY);
  setcolor(6);
  outtextxy(x/20-25,y/4+329," Copyright (c) 2006 by  ");
  outtextxy(x/20+20,y/4+344,"   ");
  setcolor(15);
  setfillstyle(7,4);
/* Tang gia tri x + 20 can chinh center cho dong chu*/
 }
//***************************************************************************
void Menu(int i)
 {
  int x=getmaxx(),y=getmaxy();
  char p;
  switch(i)
   {
	case 1:
	  CmdButton(x/20-20,y-158,x/3-20,y-140, WHITE,DARKGRAY,"GIOI THIEU",BLUE,LIGHTGRAY);
	  SelectBox(1);Gioithieu();break;
	case 2:
	  CmdButton(x/20-20,y-137,x/3-20,y-119, WHITE,DARKGRAY,"Them ",BLUE,LIGHTGRAY);
	  SelectBox(2);MakeDictionary();break;
	case 3:
	  CmdButton(x/20-20,y-116,x/3-20,y-98, WHITE,DARKGRAY,"Tim kiem",BLUE,LIGHTGRAY);
	  SelectBox(3);FindWord();break;
	case 4:
	  CmdButton(x/20-20,y-95,x/3-20,y-77, WHITE,DARKGRAY,"Hien thi",BLUE,LIGHTGRAY);
	  break;
	case 5:
	  CmdButton(x/20-20,y-74,x/3-20,y-56, WHITE,DARKGRAY,"EXIT",BLUE,LIGHTGRAY);
	  SelectBox(5);Exit();break;
   }
 }
//***************************************************************************
int main(void)
{
  /* Yeu cau tu dong phat hien */
  int gdriver=DETECT, gmode, errorcode;

  /*Khoi tao do hoa va bien dia phuong*/
  initgraph(&gdriver,&gmode,"D:\\TC\\BGI");

  /*Doc ket qua khoi tao*/
  errorcode=graphresult();

  if (errorcode!=grOk)/* Co loi do hoa*/
   {
	printf(" Loi do hoa : %s\n",grapherrormsg(errorcode));
	printf("An phim bat ky de ket thuc");
	getch();
	exit(1);
   }

  int x=getmaxx();
  int y=getmaxy();
  Graphics();
  CmdButton(x/20-20,y-158,x/3-20,y-140, WHITE,DARKGRAY,"GIOI THIEU",BLUE,LIGHTGRAY);
  CmdButton(x/20-20,y-137,x/3-20,y-119, WHITE,DARKGRAY,"Them",BLUE,LIGHTGRAY);
  CmdButton(x/20-20,y-116,x/3-20,y-98, WHITE,DARKGRAY,"Tim",BLUE,LIGHTGRAY);
  CmdButton(x/20-20,y-95,x/3-20,y-77, WHITE,DARKGRAY,"Hien thi ",BLUE,LIGHTGRAY);
  CmdButton(x/20-20,y-74,x/3-20,y-56, WHITE,DARKGRAY,"EXIT",BLUE,LIGHTGRAY);
  int k=1;
  char ch=0;
  SelectBox(k);
	 while(!done)
	  {
	   ch=getch();
	   switch (ch)
		{
		 case Down : DeSelectBox(k);
						 if(k<5) SelectBox(++k);
						 else
						  {
							k=1;
							SelectBox(k);
						  }
						 break;
		 case Up   : DeSelectBox(k);
						 if(k>1) SelectBox(--k);
						 else
						  {
							k=5;
							SelectBox(k);
						  }
						 break;
		 case Enter: Menu(k);
						 break;
		}
	  }
  getch();
  return 0;
}
 
Bạn viết bằng công cụ gì thế, tôi mở bằng Viusal C++ 6.0 không được.
 
Tiếc quá, C++ 6.0 không mở được vì không có graphics.h, thôi tôi ráng tưởng tượng ra vậy :D . Ở đây chắc hiếm ai còn dùng bản 3.0.
 
thì bác cố xem giúp em cái.sao cho vao C++6.0 ko chay đc a`.chán nhỉ.bác cố xem giúp em cái còn mỗi phần đồ họa phải hoàn thành.hay em gửi cho bác phần cài C++3.0 nhé.
 
Back
Top