1. Trang chủ
  2. » Khoa Học Tự Nhiên

Giáo trình phân tích quy trình ứng dụng điều chế thiết bị bán dẫn chứa các mạch logic điện tử p7

11 196 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 11
Dung lượng 189,79 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Trang 1

if ((buf = farmalloc(size)) == NULL)

{

OutMessage("Error: not enough heap space in save_screen()."); getch();

closegraph();

exit(1);

}

else

{

getimage(x1,y,x,y1,buf);

OutMessage("Click a drive name in the list");

}

setfillstyle(SOLID_FILL,WHITE);

bar(x1,y,x,y1);

setcolor(BLACK);

rectangle(x,y,x1,y1);

setcolor(LIGHTGRAY);

line(x-1,y+1,x-1,y1-1);

line(x1+1,y1-1,x-1,y1-1);

setcolor(BLACK);

char Temp[3];

for(int i=0;i<NumDisk;i++)

{

sprintf(Temp,"%c:",DiskName[i]);

outtextxy(x1+10,y+10+i*14,Temp);

}

for(i=0;i<NumDisk;i++)

if(*DName==DiskName[i])

break;

setfillstyle(SOLID_FILL,BLUE);

bar(x1+1,y+7+14*i,x-1,y+7+14+14*i);

setcolor(YELLOW);

sprintf(Temp,"%c:",DiskName[i]);

outtextxy(x1+10,y+10+i*14,Temp);

LPEVENT LpEvent;

do

{

ShowMouse();

delay(50);

LpEvent=GetEvent();

HideMouse();

if(LpEvent->Msg==1)

for(i=0;i<NumDisk;i++)

if(LpEvent->Posx>=x1+1&&LpEvent->Posx<=x-1&&LpEvent->Posy>=y+7+i*14&&LpEvent->Posy<=y+7+14+i*14)

{

bar(x1+1,y+7+14*i,x-1,y+7+14+14*i);

*DName=DiskName[i];

setdisk((int)*DName-65);

}

}while(LpEvent->Msg!=1);

putimage(x1,y,buf,COPY_PUT);

farfree(buf);

return LpEvent;

}

// -

char *FileType(TEXTBOX *b)

{

char s[15];

Trang 2

b->Path();

b->OutTextBox();

b->GetS(s);

return s;

}

VI.CLASS LIST.HPP

#include "textbox.hpp"

#include "disklist.hpp"

#if !defined LIST

#define LIST

class LIST

{

private:

int l,t,r,b;

int Color;

public:

void InitList(int x1,int y1,int x2,int y2,int Color);

void Show();

int Press(char s[],TEXTBOX *Box,unsigned *attrib,char

*DiskName,char *DName,char *ftype);

int GetList(char s[],TEXTBOX *Box,unsigned *attrib,char

*DiskName,char *DName,TEXTBOX *Box2,char *ftype);

int Left(){return l;};

int Right(){return r;};

int Top(){return t;};

int Bottom(){return b;};

};

#endif

VII.MODULE LIST.CPP

#include <graphics.h>

#include <dir.h>

#include <dos.h>

#include <stdlib.h>

#include <string.h>

#include <alloc.h>

#include <stdio.h>

#include <conio.h>

#include <ctype.h>

#include "mouse.h"

#include "list.hpp"

// -

void LIST::InitList(int x1,int y1,int x2,int y2,int col)

{

Color=col;

l=x1;t=y1;r=x2;b=y2;

}

// -

void LIST::Show()

{

setfillstyle(SOLID_FILL,Color);

bar(l,t,r,b);

int hor=(r-l)/3,ver=(b-t)/3;

int x1=l+hor,x2=r-hor,x3=l+(r-l)/2,y1=t+ver,y2=t+ver,y3=b-ver; setcolor(WHITE);

line(x1,y1,x2,y2);

line(x2,y2,x3,y3);

line(x1,y1,x3,y3);

setfillstyle(SOLID_FILL,WHITE);

floodfill(x1+(x2-x1)/2,y1+(y3-y2)/2,WHITE);

Trang 3

setfillstyle(SOLID_FILL,Color);

setcolor(BLACK);

line(l,b,r,b);

line(r,t,r,b);

setcolor(WHITE);

line(l,t,r,t);

line(l,t,l,b);

}

// -

int LIST::Press(char s[],TEXTBOX *Box,unsigned *attrib,char

*DiskName,char *DName,char *ftype)

//tra ve 0:nhan Cancel

//tra ve 1:nhan OK

{

TEXTBOX Box2;

HideMouse();

int hor=(r-l)/3,ver=(b-t)/3;

int x1=l+hor,x2=r-hor,x3=l+(r-l)/2,y1=t+ver,y2=t+ver,y3=b-ver; setcolor(BLACK);

line(x1,y1,x2,y2);

line(x2,y2,x3,y3);

line(x1,y1,x3,y3);

setfillstyle(SOLID_FILL,BLACK);

floodfill(x1+(x2-x1)/2,y1+(y3-y2)/2,BLACK);

setfillstyle(SOLID_FILL,Color);

setcolor(WHITE);//vien cho nut bi nhan

line(l,b,r,b);

line(r,t,r,b);

setcolor(BLACK);//vien cho nut bi nhan

line(l,t,r,t);

line(l,t,l,b);

int k=0;

*DName=Disk(DiskName);

do

{

char buffer[MAXPATH];

k=GetList(s,Box,attrib,DiskName,DName,&Box2,ftype);

getcwd(buffer, MAXPATH);

Box->GetS_in(buffer);

Box->OutTextBox();

}while(k==2);

ShowMouse();

return k;//k=0: nhan Cancel, k=1:nhan OK

}

// -

int LIST::GetList(char s[],TEXTBOX *Box,unsigned *attrib,char

*DiskName,char *DName,TEXTBOX *Box2,char *ftype)

{

int x11=l-300,y11=b,x12=r+100,y12=b+300;//toa do bang ngoai

//600 x 300 la kich thuoc bang ngoai

int Kiemtra=0;//bien de kiem tra truong hop chon OK truoc khi chon file

LPEVENT lpEvent;//kiem tra bang thu muc

void far *buf;//con tro chi vung luu tru man hinh

Trang 4

unsigned int size = imagesize(x11,y11,x12,y12);

if ((buf = farmalloc(size)) == NULL)

{

OutMessage("Error: not enough heap space in save_screen()."); getch();

closegraph();

exit(1);

}

else

{

getimage(x11,y11,x12,y12, buf);

OutMessage("Choose a file name then click OK to accept or click Cancel to ignore");

}

setfillstyle(SOLID_FILL,LIGHTGRAY);//GREEN);

bar(x11,y11,x12,y12);//ve bang ngoai

int x21=x11+5,y21=y11+5,x22=x12-120,y22=y12-77;//75;//toa do bang liet ke

setfillstyle(SOLID_FILL,WHITE);//MAGENTA);

bar(x21,y21,x22,y22);//ve bang liet ke

int x31=x22+30,y31=y21+50,x32=x31+60,y32=y31+20;//toa do nut OK int x41=x31,y41=y31+100,x42=x32,y42=y32+100;

setcolor(WHITE);

line(x11,y11,x12,y11);

line(x11,y11,x11,y12);

line(x22+2,y21-2,x22+2,y22+2);//vien cho bang liet ke

line(x21-1,y22+2,x22+2,y22+2);//vien cho bang liet ke

line(x31,y31,x32,y31);//vien cho nut OK

line(x31,y31,x31,y32);//vien cho nut OK

line(x41,y41,x42,y41);//vien nut Cancel

line(x41,y41,x41,y42);//vien nut Cancel

setcolor(BLACK);

line(x12,y11,x12,y12);

line(x11,y12,x12,y12);

line(x21,y21,x22,y21);//vien cho bang liet ke

line(x21,y21,x21,y22);//vien cho bang liet ke

line(x32,y31,x32,y32);//vien cho nut OK

line(x31,y32,x32,y32);//vien cho nut OK

line(x42,y41,x42,y42);//vien nut Cancel

line(x41,y42,x42,y42);//vien nut Cancel

setcolor(DARKGRAY);

line(x21-1,y21-1,x22+1,y21-1);//vien cho bang liet ke

line(x21-1,y21-1,x21-1,y22+1);//vien cho bang liet ke

setcolor(BLUE);

char S3[]="OK",S4[]="Cancel";

Trang 5

int x33=x31+(x32-x31-textwidth(S3))/2;

int y33=y31+(y32-y31-textheight(S3))/2;

outtextxy(x33,y33,S3);

int x44=x41+(x42-x41-textwidth(S4))/2;

int y44=y41+(y42-y41-textheight(S4))/2;

outtextxy(x44,y44,S4);

struct ffblk FF;

struct ffblk Lis[200];

char path[100];

getcurdir(0, path);

int done;

int x51=x21,x52=x51+130,y51=y22+28,y52=y51+20;

int x61=x21,x62=x12-5,y61=y12-25,y62=y12-5;

Box2->InitTextBox(x51,y51,x52,y52,WHITE,LIGHTBLUE,"Type of file"); Box2->GetS_in(ftype);

Box2->OutTextBox();

setcolor(BLACK);

line(x51+1,y51+1,x52-1,y51+1);

line(x51+1,y51+1,x51+1,y52-1);

setcolor(LIGHTGRAY);

line(x51+1,y52-1,x52-1,y52-1);

line(x52-1,y51+1,x52-1,y52-1);

setfillstyle(SOLID_FILL,WHITE);

bar(x61,y61,x62,y62);

setcolor(BLACK);

line(x61,y61,x62,y61);

line(x61,y61,x61,y62);

line(x61+1,y61+1,x62-1,y61+1);

line(x61+1,y61+1,x61+1,y62-1);

setcolor(LIGHTGRAY);

line(x62-1,y61+1,x62-1,y62-1);

line(x61+1,y62-1,x62-1,y62-1);

//DiskBox

int x71=x52+30,x72=x22,y71=y51,y72=y52;//toa do DiskBox

char DNameTemp[4];

sprintf(DNameTemp,"%c:",*DName);

TEXTBOX DiskBox;

DiskBox.InitTextBox(x71,y71,x72,y72,WHITE,LIGHTBLUE,"Driver name"); DiskBox.GetS_in(DNameTemp);

DiskBox.OutTextBox();

setcolor(BLACK);

line(x71+1,y71+1,x72-1,y71+1);

line(x71+1,y71+1,x71+1,y72-1);

setcolor(LIGHTGRAY);

line(x71+1,y72-1,x72-1,y72-1);

line(x72-1,y71+1,x72-1,y72-1);

LIST DriList;//nut nhan chon o dia

int x81=x72-19,y81=y71+2,x82=x72-2,y82=y72-2;

DriList.InitList(x81,y81,x82,y82,LIGHTGRAY);

DriList.Show();

done=findfirst("*",&FF,FA_DIREC);

Lis[0]=FF;

int dem=0;//cho vong while tim file, la so files + thu muc tim duoc

Trang 6

if((int)Lis[0].ff_attrib!=16) dem-=1;

while (!done)//nhap ten file vao mang cau truc FF

{

dem++;

done = findnext(&FF);

if(!done)

Lis[dem]=FF;

if((int)Lis[dem].ff_attrib!=16) dem-=1;

}

dem+=1;

int NumDir=dem;

done=findfirst(ftype,&FF,FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_ARCH); for(int j=0;j<strlen(FF.ff_name)+1;j++)

Lis[dem].ff_name[j]=tolower(FF.ff_name[j]);

while (!done)//nhap ten file vao mang cau truc FF

{

dem++;

done = findnext(&FF);

for(int j=0;j<strlen(FF.ff_name)+1;j++)

Lis[dem].ff_name[j]=tolower(FF.ff_name[j]);

}

int NumFile=dem-NumDir;

char Note[50];//[30];

setcolor(BLACK);

sprintf(Note,"%d files and %d directories found",NumFile,NumDir); outtextxy(x61+5,y61+(y62-y61-textheight(Note))/2,Note);

int temp=y11,Dem=0,i;

if(dem==0)//truong hop dia hoan toan trong, neu la mot thu muc rong thi khong thuoc truong hop nay

strcpy(Lis[0].ff_name,"");

int tempx1=x21+1,tempx2=x22,tempy1=y11+14-3,tempy2=y11+14+8+3; setcolor(BLACK);//LIGHTGREEN);

for(i=0;i<15&&i<dem;i++)//hien thi ten file

outtextxy(x21+8,temp+=14,Lis[i].ff_name);

setfillstyle(SOLID_FILL,BLUE);

bar(tempx1,tempy1,tempx2,tempy2);

setcolor(YELLOW);

outtextxy(x21+8,y11+14,Lis[0].ff_name);//vach sang tai vi tri dau tien

int oldx1=tempx1,oldy1=tempy1,oldx2=tempx2,oldy2=tempy2;

int over=0;

int ppp=0;

do//while(1);

{

ShowMouse();

lpEvent = GetEvent();//lay bien co chuot

int j,nhanphim;

if(kbhit())//kiem tra co nhan phim

{ nhanphim=getch();

if(nhanphim==0)

nhanphim=getch();

}

{

switch(nhanphim)

{

Trang 7

case 81://page down

if(ppp++ >12)//17) ppp=0;

else goto MouseDown;

case 80: // mui ten xuong

nhanphim=1;

MouseDown:

HideMouse();

if(Dem<14/*9*/&&Dem<dem-1)j=Dem+1;//&&Dem<dem-1 else

{ over++;

if((over)>=(dem-14))//9)) {

over ;

goto End;

} j=Dem;

setcolor(WHITE);//MAGENTA);

temp=y11;

for(i=over-1;(i<15+over-1)&&i<dem;i++)//xoa ten file

outtextxy(x21+8,temp+=14,Lis[i].ff_name);

setcolor(BLACK);//LIGHTGREEN);

temp=y11;

for(i=over;(i<14+over)&&i<dem;i++)

outtextxy(x21+8,temp+=14,Lis[i].ff_name);

} goto Arrowkey;//break;

case 73://page up

if(ppp++ >12) ppp=0;

else goto MouseUp;

case 72: // len

nhanphim=1;

MouseUp:

HideMouse();

if(Dem>0) j=Dem-1;

else { over ;

if((over)<=-1) {

over++;

goto End;

} j=Dem;

setcolor(WHITE);//MAGENTA);

temp=y11;

for(i=over+1;i<15+over+1;i++)//xoa ten file

outtextxy(x21+8,temp+=14,Lis[i].ff_name);

setcolor(BLACK);//LIGHTGREEN);

temp=y11;

for(i=over;i<15+over;i++)

outtextxy(x21+8,temp+=14,Lis[i].ff_name);

} goto Arrowkey;//break;

case 13://Enter nhanphim=1;

goto nutOK;

case 27://Esc nhanphim=1;

Trang 8

goto nutCancel;

}

}//if(kbhit())

/////////////////////////////////// xet mouse

if(lpEvent->Msg==1)//neu nhan phim trai chuot

{

if(lpEvent->Posx>=x51&&lpEvent->Posx<=x52&&lpEvent->Posy>=y51&&lpEvent->Posy<=y52)

{//get type of file

HideMouse();

OutMessage("Enter type of file then press Enter to accept or Esc to ignore.");

Box2->Path();//lay Path vao bien S cua TEXTBOX

Box2->GetS(ftype);

putimage(x11,y11,buf,COPY_PUT);

farfree(buf);

ShowMouse();

return 2;

}

if(lpEvent->Posx>=x71&&lpEvent->Posx<=x72-20&&lpEvent->Posy>=y71&&lpEvent->Posy<=y72)

{//change disk trong diskbox

int ExistDisk;

char OldDisk=toupper(*DName);

OutMessage("Enter name of drive");

do

{

HideMouse();

DiskBox.Path();//lay Path vao bien S cua TEXTBOX

DiskBox.GetS(DNameTemp);

DNameTemp[0]=toupper(DNameTemp[0]);

*DName=DNameTemp[0];

ExistDisk=0;

for(int k=0;k<strlen(DiskName);k++)

if(*DName==DiskName[k]) ExistDisk=1;

if(ExistDisk!=1)

{

OutMessage("Press Enter to do the action again or Esc to ignore");

if(OutError("Disk not exist")==0) {

*DName=OldDisk;

break;

} }

ShowMouse();

}while(!ExistDisk);

if(OldDisk!=*DName) //truong hop chon dia bang nut

pulldown nhung lai chon kieu go ky tu vao textbox

setdisk(*DName-'A');

HideMouse();

putimage(x11,y11,buf,COPY_PUT);

farfree(buf);

ShowMouse();

return 2;

}

if(lpEvent->Posx>=x81&&lpEvent->Posx<=x82&&lpEvent->Posy>=y81&&lpEvent->Posy<=y82)

Trang 9

{//choose disk

HideMouse();

setcolor(BLACK);

line(x81,y81,x82,y81);

line(x81,y81,x81,y82);

line(x81+1,y81-1,x81+1,y82-1);

char OldDName=*DName;

CheckChooseDisk(DiskName,DName,lpEvent,x82,y82);

if(OldDName!=*DName)

{

putimage(x11,y11,buf,COPY_PUT);

farfree(buf);

return 2;

}

setcolor(WHITE);

line(x81,y81,x82,y81);

line(x81,y81,x81,y82);

line(x81+1,y81-1,x81+1,y82-1);

ShowMouse();

}

for(j=0;j<15&&j<dem&&lpEvent->Msg==1;j++)//kiem tra file chon neu co chon

if(tempx1<= lpEvent->Posx&&tempx2>=lpEvent->Posx)

if((tempy1+j*14)<=lpEvent->Posy&&(tempy2+j*14)>=lpEvent->Posy)

{

Arrowkey:

HideMouse();

setfillstyle(SOLID_FILL,WHITE);//MAGENTA);

bar(oldx1,oldy1,oldx2,oldy2);

setcolor(BLACK);//LIGHTGREEN);

outtextxy(x21+8,oldy1+3,Lis[Dem+over].ff_name);

setfillstyle(SOLID_FILL,BLUE);

oldx1=tempx1, oldy1=tempy1+j*14,oldx2=tempx2,oldy2=tempy2+j*14;

bar(oldx1,oldy1,oldx2,oldy2);

setcolor(YELLOW);

outtextxy(x21+8,oldy1+3,Lis[j+over].ff_name);

_dos_getfileattr(Lis[j+over].ff_name,attrib);

strcpy(s,Lis[j+over].ff_name);

if(strcmp(s,".")==0) strcpy(s,"\\");

Dem=j;

End:

Kiemtra=1;//bao hieu co nhan vao list }

if(>Msg==1&&(j==15)&&tempx1<=

lpEvent-

>Posx&&tempx2>=lpEvent->Posx&&(tempy1+j*14)<=lpEvent->Posy&&(tempy2+j*14)>=lpEvent->Posy)

//truong hop vet tro file o cuoi bang list va nhap chuot ngay ben duoi vet tro

{

lpEvent->Posx=x11;

lpEvent->Posy=y11;

delay(50);

goto MouseDown;

}

if(>Msg==1&&(j==15)&&tempx1<=

lpEvent- >Posx&&tempx2>=lpEvent->Posx&&(tempy1-14)<=lpEvent->Posy&&(tempy2-14)>=lpEvent->Posy)

Trang 10

//truong hop vet tro file o dau bang list va nhap chuot ngay ben tren vet tro

{

lpEvent->Posx=x11;

lpEvent->Posy=y11;

delay(50);

goto MouseUp;

}

if(lpEvent->Msg==1&&x31<=

lpEvent->Posx&&y31<=lpEvent->Posy&&x32>=lpEvent->Posx&&y32>=lpEvent->Posy)

nutOK:

{

HideMouse();

putimage(x11,y11,buf,COPY_PUT);

farfree(buf);

if(Kiemtra!=1)

strcpy(s,Lis[0].ff_name);

if(strcmp(s,".")==0)

{

strcpy(s,"\\");

*attrib=16;

}

if(*attrib==16)

{

chdir(s);

return 2;

}

Show();

ShowMouse();

OutMessage("Click OK to send file.");

return 1 ;//bao da co chon file

}

if(lpEvent->Msg==1&&x41<=

lpEvent->Posx&&y41<=lpEvent->Posy&&x42>=lpEvent->Posx&&y42>=lpEvent->Posy)

nutCancel:

{

HideMouse();

putimage(x11,y11,buf,COPY_PUT);

farfree(buf);

Cancel:

Show();

ShowMouse();

OutMessage("Click mouse to chose action");

return 0;

}

}

if(lpEvent->Msg==2)

{

delay(100);

goto nutOK;

}

}while(1);

}

// -

VIII CLASS MOUSE.H

#if !defined( MOUSE_H )

#define MOUSE_H

#include <dos.h>

Ngày đăng: 07/12/2015, 00:53

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm