有19楼的画面,做漂亮的界面就不成问题。

授人以渔,不授人以鱼。
程序代码:#include <Windows.h>
#include "myConsole.h"
// 菜单数据结构
struct MENU
{
size_t Bar_Number; // 选项数目
WCHAR Menu[20][80]; // 选项数组,最大20项,每项最多79个字符
WCHAR KeyCharacter[20]; // 快捷键数组,与选项对应
};
void Do_MainMenu(void);
void Show_Menu(COORD Cursor_Position, const MENU* Menu);
void Show_Message(WCHAR* Message);
myConsole _Console; // 控制台对象
void main(void)
{
_Console.SetScreenTitle(L"控制台界面测试程序");
_Console.Cls(BACKGROUND_BLUE);
_Console.NormalTextAttribute = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | BACKGROUND_BLUE; // 蓝底白字
_Console.GetTextAttribute = BACKGROUND_RED | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; // 红底黄字
Do_MainMenu();
}
// 主菜单
void Do_MainMenu(void)
{
MENU Main_Menu =
{
5, // 选项数
{
L"1.基本数据管理",
L"2.学生成绩管理",
L"3.学生选课管理",
L"4.学生宿舍管理",
L"0.结束程序返回"
},
{'1', '2', '3', '4', '0'} // 快捷键
};
COORD Position = {30, 1}; // 菜单起始坐标(X,Y)
WCHAR Choice; // 选定项目的快捷键
_Console.SetTextAttribute(_Console.NormalTextAttribute);
Show_Menu(Position, &Main_Menu);
_Console.GetScreenInfo();
Position = _Console.Screen_Info.dwCursorPosition;
do
{
_Console.CursorGoto(Position);
Choice = _Console.Get_Character(Main_Menu.KeyCharacter);
Show_Message(Main_Menu.Menu[Choice - '1']);
} while (Choice != '0');
}
// 显示菜单
// 参数:Position - 菜单起始坐标,用(X,Y)表示,X为列,Y为行,从0开始
// Menu - 菜单结构指针
void Show_Menu(COORD Position, const MENU* Menu)
{
_Console.SetTextAttribute(_Console.NormalTextAttribute);
for (size_t Index = 0; Index < Menu->Bar_Number; Index++)
{
_Console.CursorGoto(Position);
_Console.Print(Menu->Menu[Index]); // 显示菜单项
Position.Y++; // 横坐标不变转下一行
}
Position.Y++;
_Console.CursorGoto(Position);
_Console.Print(L"请选择: ");
}
void Show_Message(WCHAR* Message)
{
COORD Position = {5, 10};
_Console.CursorGoto(Position);
_Console.SetTextAttribute(_Console.NormalTextAttribute);
_Console.Print(L"您刚才选择的是: ");
_Console.Print(Message);
}