|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
RT
附代码
#include <stdio.h>
#include <Windows.h>
#include <conio.h>
#include "assert.h"
#include <stdbool.h>
#define ScreenHeight(sInfo) (sInfo.srWindow.Bottom-sInfo.srWindow.Top)
void DrawBox();
HANDLE out, in, error;
int main()
{
out = GetStdHandle(STD_OUTPUT_HANDLE);
in = GetStdHandle(STD_INPUT_HANDLE);
assert(out != INVALID_HANDLE_VALUE, "Can't Get the Out handle!\n");
assert(in != INVALID_HANDLE_VALUE, "Can't Get the In handle!\n");
DrawBox();
_getch();
CloseHandle(out);
}
void DrawBox()
{
assert(out != INVALID_HANDLE_VALUE);
CONSOLE_SCREEN_BUFFER_INFO sInfo;
GetConsoleScreenBufferInfo(out, &sInfo);
DWORD n;
FillConsoleOutputAttribute(out,
BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE, 3600, (COORD) { 0 }, &n);
SetConsoleTextAttribute(out,
BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE, 3600, (COORD) { 0 }, &n);
wchar_t c[] = L"There is a string in a box!";
RECT rect = { sInfo.dwSize.X/4,ScreenHeight(sInfo)/4,
sInfo.dwSize.X/4+wcslen(c)*2,ScreenHeight(sInfo) / 4*3 };
for (UCHAR i = rect.top; i < rect.bottom; i++)
{
FillConsoleOutputAttribute(out, BACKGROUND_INTENSITY,
rect.right - rect.left + 1, (COORD) { rect.left, i }, &n);
}
rect.left -= 3;
rect.top -= 1;
rect.bottom -= 1;
rect.right -= 3;
for (UCHAR i = rect.top; i < rect.bottom; i++)
{
FillConsoleOutputAttribute(out, BACKGROUND_RED,
rect.right - rect.left + 1, (COORD) { rect.left, i }, &n);
}
rect.left += 9; rect.right += 9;
rect.top += 3; rect.bottom += 3;
WriteConsoleOutputCharacter(out, c, wcslen(c),
(COORD) {
rect.left, rect.top
}, &n);
}
|
-
|