.


:




:

































 

 

 

 


13.




: , MS DOS, .

/* 13.1 . , , : - 0 ('\0') - . */

#include <stdio.h>

#include <conio.h> //

//

void main()

{ char ch;

textbackground(BLACK); //

gotoxy(20, 24); // =20, y=24

cprintf(" .");

gotoxy(20, 25); // :

cprintf(" : _F4 _Esc");

clrscr();

window(1, 1, 15, 11); //

textbackground(LIGHTGRAY); //

textcolor(YELLOW); //

clrscr(); //

// :

gotoxy(2, 3); printf(" F1 - _1");

gotoxy(2, 5); printf(" F2 - _2");

gotoxy(2, 7); printf(" F3 - _3");

gotoxy(2, 9); printf(" F4 - ");

_setcursortype(_NOCURSOR); //

do

{ ch = getch();

if (ch == '\0') //...,

{ ch = getch(); //

switch (int(ch)) //

// : F1,F2,F3 F4!

{

case 59: // F1 _1:

{ window(22, 1, 32, 10); textbackground(BLUE);

_setcursortype(_NORMALCURSOR); //

clrscr(); break; }

case 60: // F2 - _2:

{ window(34, 1, 44, 15); textbackground(RED);

clrscr(); break; }

case 61: // F3 - _3:

{ window(46, 1, 56, 20); textbackground(GREEN);

clrscr(); break; }

case 62: exit(0); //

}// switch

} // if < then >

else putch(ch); //

}

while (int(ch)!= 27); // Esc

}

/* 13.2 conio:

clrscr() gotoxy() textcolor()

cputs() insline() textmode()

delline() kbhit() wherex()

getch() putch() wherey()

gettextinfo() textbackground() window()

:

1. initialize():

4350: 88 (43/50 EGA/VGA);

(last_col last_row) , ;

(randomize()).

2. makewindow() - .

3. randomtext() - , , .

 

3. main():

initialize();

_Esc:

, .

:

_Ins - ,

_Del - ,

_Enter - ,

<-> - ,

_Alt-R - ,

_Alt-W - ,

_Esc - .

#include <stdio.h>

#include <conio.h> //

#include <stdlib.h> // random(int num) -

// (0, num-1)

#include <dos.h> // delay(ms) -

// (ms)

#include <time.h> // randomize() random()

int last_col, last_row; //

struct text_info ti; //

void randomtext();

void initialize();

void makewindow();

 

 

main()

{ char ch;

int done, wx, wy;

initialize();

done = 1; // : (done = = 1)

do

{ ch = getch();

if (ch == '\0') //...,

{ ch = getch();

switch (int(ch))

{ case 17: { makewindow(); break; } // Alt-W

case 19: { randomtext(); break; } // Alt-R

case 45: { done = 1; break; } // Alt-X

case 72: { wx=wherex(); wy=wherey()-1;

gotoxy(wx, wy); break; } // Up -

case 75: { wx=wherex()-1; wy=wherey();

gotoxy(wx, wy); break; } // Left -

case 77: { wx=wherex()+1; wy=wherey();

gotoxy(wx, wy); break; } // Right -

case 80: { wx=wherex(); wy=wherey()+1;

gotoxy(wx, wy); break; } // Down -

case 82: { insline(); break; } // Ins -

case 83: { delline(); break; } // Del -

}

}

else //

switch (int(ch))

{ case 13: { putch('\n'); putch('\r'); break; } // Enter

//

case 27: { done = 0; break; } // Esc -

default: { putch(ch); break; } //

}

} while (done == 1);

textmode(LASTMODE); //

} // main()

void initialize()

{ char ch;

clrscr(); //

textmode(C4350); // 43/50 EGA/VGA

gettextinfo(&ti); // , ,

// ,

last_col = ti.winright; // ( )

last_row = ti.winbottom; // ( )

gotoxy(1,last_row); //

textbackground(BLACK); // - ,

textcolor(WHITE); // -

// :

cputs(" Ins-InsLine Del-DelLine "); // "..."

ch = char(27); putch(ch); //

ch = char(24); putch(ch); //

ch = char(25); putch(ch); //

ch = char(26); putch(ch); //

cputs(" - cursor ");

cputs("Alt-W-Window Alt-R-Random Esc-Exit");

last_row--; //

randomize(); //

} // initialize()

void makewindow()

{ int x, y, width, height, xw, yh, col;

width = random(last_col-2)+2; // ,

height = random(last_row-2)+2; // -

x = random(last_col-width)+1; // x, y -

y = random(last_row-height)+1; //

xw = x+width; yh = y+height;

window(x, y, xw, yh); //

col = random(8);

textbackground(col); //

col= random(7)+9;

textcolor(col); //

clrscr();

} // makewindow()

void randomtext()

{ char ch;

do

{ ch = char(random(224)+32);

// , ( < 32)

putch(ch); delay(20); // 20 ms

} while (!kbhit()); //...,

}

/* 13.3. .

:

" ch " , win1();

" " " ch ", win2();

" " , win3(). */

#include <stdlib.h>

#include <stdio.h>

#include <conio.h>

#include <dos.h>

void win1(); //

void win2(); // " ch "

void win3(); //

void win_menu(COLORS Col, int k); // k -

// , Col

void main()

{ int k=1,f=0; char ch;

clrscr(); // :

_setcursortype(_NOCURSOR);

textcolor(YELLOW);

win_menu(LIGHTGRAY, 1);

win_menu(BLUE, 2);

win_menu(BLUE, 3);

do { //

ch=getch();

if(ch=='\0') //

{ win_menu(BLUE,k);

ch=getch();

switch(ch)

{ case 77: { k++; if(k>3) k=1; break; }

case 75: { k--; if(k<1) k=3; break; }

}

win_menu(LIGHTGRAY, k);

}

if(ch==13) // _Enter

switch(k)

{ case 1: { win1(); break; }

case 2: { win2(); break; }

case 3: win3(); //

ch = 27;

}

} while(ch!= 27); // _Esc

// , _Esc
// , :

_setcursortype(_NORMALCURSOR);

textattr(0x7);

window(1, 1, 80, 25);

clrscr();

} // main()

void win_menu(COLORS Col, int k)

{ textbackground(Col);

window((k-1)*10+1, 1, k*10, 1); clrscr();

if(k==1) cprintf(" ch ");

if(k==2) cprintf(" ");

if(k==3) cprintf(" ");

} win_menu()

void win1()

{ int f=1; char ch;

textbackground(3);

window(10,3,50,12);

clrscr();

cprintf("\n : \n\r");

while(ch!=27)

{ ch=getch();

if(f)

cprintf("%c", ch);

if(ch>='0' && ch<='9') f=0;

}

} // win1()

void win2()

{ char ch;

textbackground(2);

window(10,14,70,25);

clrscr();

cprintf(" ");

cprintf("\n\r 1");

cprintf("\n\r ");

cprintf("\n\r 1 ");

cprintf("\n\r !");

cprintf("\n\r _Esc ");

ch=getch();

while(ch!=27)

} // win2()

void win3()

{ char ch;

_setcursortype(_NORMALCURSOR);

textattr(0x7);

window(1, 1, 80, 25); clrscr();

}

1. , ?

2. , . .

3. , 5 .





:


: 2015-10-01; !; : 520 |


:

:

- , .
==> ...

2017 - | 1802 -


© 2015-2024 lektsii.org - -

: 0.034 .