Нано прямоуг. рамку развернуть на весь экран.
Вот кодогавно:
#include <graphics.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include "keyboard.h"
#define M_LEFT 40
#define M_RIGHT 450
#define M_TOP 10
#define M_BOTTOM 250
#define MIAU_X 800
#define MIAU_Y 200
#define ACTIVE_COLOR RED
#define PASSIVE_COLOR YELLOW
#define ACTIVE_BACK_COLOR BROWN
#define PASSIVE_BACK_COLOR DARKGRAY
#define BORDER_COLOR GREEN
#define kbSpace 32
//PROTIPES
void Cat(void);
void Mouse(void);
void Dog(void);
void Sheep(void);
int GrMenu (char *Items[], int N, int Left, int Top, int Right, int Bottom);
void DrawMenu(char *Items[], int N, int Left, int Top, int Right, int Bottom, int active);
//**********************************************************************************
void main (void)
{
char *Items[]={"Dog","Cat","Mouse","Sheep","Exit"};
int choise,N = 5;
int a=DETECT,b;
initgraph(&a,&b,"");
setbkcolor(BLUE);
outtextxy(M_LEFT +40, M_TOP -10, "This text typed only once!!!Then restored by Menu function");
b = 1;
do
{
choise = GrMenu(Items, N, M_LEFT, M_TOP, M_RIGHT, M_BOTTOM);
switch(choise)
{
case -1:
case 4: b = 0; break;
case 0: Dog(); break;
case 1: Cat(); break;
case 2: Mouse(); break;
case 3: Sheep(); break;
}
}
while(b);
sleep(2);
closegraph();
}
// Функция выводит в прямоугольнике по переданным координатам на графический экран // меню из N пунктов, которые получает в массиве Items. Перед завершением функция // восстанавливает затёртое её изображение
int GrMenu (char *Items[], int N, int Left, int Top, int Right, int Bottom)
{
long sz = imagesize(Left, Top, Right, Bottom);
void *image = malloc(sz);
if (image == NULL) return -1;
getimage(Left, Top, Right, Bottom, image);
int choise = 0, Done = 0;
do
{
DrawMenu(Items, N, Left, Top, Right, Bottom, choise);
int key = GetCh();//Key();
switch (key)
{
case kbUp: if (choise > 0) choise–;else choise = N - 1; break;
case kbDown: if (choise < N - 1) choise++;else choise = 0; break;
case kbEsc: choise = -1; Done = 1; break;
case kbEnter:
case kbSpace: Done = 1; break;
}
}
while (!Done);
putimage(Left, Top, image, COPY_PUT);
free(image);
return choise;
}
void DrawMenu(char *Items[], int N, int Left, int Top, int Right, int Bottom, int active)
{
setcolor(BORDER_COLOR);
rectangle(Left, Top, Right, Bottom);
setfillstyle(SOLID_FILL, PASSIVE_BACK_COLOR);
bar(Left + 1, Top + 1, Right - 1, Bottom - 1);
settextstyle(GOTHIC_FONT, HORIZ_DIR, 3);
settextjustify(CENTER_TEXT, CENTER_TEXT);
setfillstyle(SOLID_FILL, ACTIVE_BACK_COLOR);
int x = Left+Left/9;
int y = (Bottom + Right) / 3;
int dx = (Right - Left) / (N - 1);
int dy = (Bottom - Top) / 2; // 2;
for (int i = 0; i < N; i++)
{
x = Left + (i + 1) * dx;
// y = Top + (i + 1) * dy;
if (i == active)
{
setcolor(BORDER_COLOR);
rectangle(x + 25, y + 10, x - 25 , y - 10);
setcolor(ACTIVE_COLOR);
}
else setcolor(PASSIVE_COLOR);
outtextxy(x, y, Items);
}
}
void Cat (void)
{
setcolor(RED);
settextstyle(0, HORIZ_DIR, 1);
settextjustify(LEFT_TEXT, TOP_TEXT);
setfillstyle(SOLID_FILL, GREEN);
bar(MIAU_X, MIAU_Y, MIAU_X + 100, MIAU_Y + 50);
outtextxy(MIAU_X, MIAU_Y, "Mi-a-a-u!!");
outtextxy(MIAU_X, MIAU_Y + 30, "push any key");
getch();
}
void Mouse (void)
{
setcolor(GREEN);
settextstyle(0, HORIZ_DIR, 1);
settextjustify(LEFT_TEXT, TOP_TEXT);
setfillstyle(SOLID_FILL, RED);
bar(MIAU_X, MIAU_Y, MIAU_X + 100, MIAU_Y + 50);
outtextxy(MIAU_X, MIAU_Y, "PI-pi-pi");
outtextxy(MIAU_X, MIAU_Y + 30, "push any key");
getch();
}
void Dog (void)
{
setcolor(YELLOW);
settextstyle(0, HORIZ_DIR, 1);
settextjustify(LEFT_TEXT, TOP_TEXT);
setfillstyle(SOLID_FILL, BROWN);
bar(MIAU_X, MIAU_Y, MIAU_X + 100, MIAU_Y + 50);
outtextxy(MIAU_X, MIAU_Y, "Gaw-gav!!");
outtextxy(MIAU_X, MIAU_Y + 30, "push any key");
getch();
}
void Sheep (void)
{
setcolor(BLUE);
settextstyle(0, HORIZ_DIR, 1);
settextjustify(LEFT_TEXT, TOP_TEXT);
setfillstyle(SOLID_FILL, WHITE);
bar(MIAU_X, MIAU_Y, MIAU_X + 100, MIAU_Y + 50);
outtextxy(MIAU_X, MIAU_Y, "Be-e-e-e!!");
outtextxy(MIAU_X, MIAU_Y + 30, "push any key");
getch();
}