64,637
社区成员
发帖
与我相关
我的任务
分享
void DrawT(int X, int Y, CColor Color, int Font, bool Center, char* _Input, ...)
{
char Buffer[1024] = { '\0' };
/* set up varargs*/
va_list Args;
va_start(Args, _Input);
vsprintf_s(Buffer, _Input, Args);
va_end(Args);
size_t Size = strlen(Buffer) + 1;
/* set up widebuffer*/
wchar_t* WideBuffer = new wchar_t[Size];
/* char -> wchar */
mbstowcs_s(nullptr, WideBuffer, Size, Buffer, Size - 1);
/* check center */
int Width = 0, Height = 0;
if (Center)
{
GetTextSize(Font, WideBuffer, Width, Height);
}
/* call and draw*/
DrawSetTextColor(Color._color[0], Color._color[1], Color._color[2], Color._color[3]);
DrawSetTextFont(Font);
DrawSetTextPos(X - (Width / 2), Y);
DrawPrintText(WideBuffer, wcslen(WideBuffer));
return;
}
void DrawString(int font, int x, int y, int align, CColor color, const wchar_t* text, ...)
{
DrawSetTextPos(x, y);
DrawSetTextColor(color._color[0], color._color[1], color._color[2], color._color[3]);
DrawSetTextFont(font);
DrawPrintText(text, wcslen(text));
return;
}
#pragma comment(lib,"user32")
#pragma comment(lib,"gdi32")
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
HWND WINAPI GetConsoleWindow();
void HideTheCursor() {
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if(GetConsoleCursorInfo(hStdOut, &cciCursor)) {
cciCursor.bVisible = FALSE;
SetConsoleCursorInfo(hStdOut, &cciCursor);
}
}
void ShowTheCursor() {
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if(GetConsoleCursorInfo(hStdOut, &cciCursor)) {
cciCursor.bVisible = TRUE;
SetConsoleCursorInfo(hStdOut, &cciCursor);
}
}
int main() {
HWND hwnd;
HDC hdc;
HFONT hfont;
system("color F0");
system("cls");
HideTheCursor();
hwnd = GetConsoleWindow();
hdc = GetDC(hwnd);
hfont = CreateFont(48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "宋体");
SelectObject(hdc,hfont);
TextOut(hdc,10,10,"地球人都知道!",14);
MoveToEx(hdc,5,5,NULL);
LineTo(hdc,300, 5);
LineTo(hdc,300, 60);
LineTo(hdc, 5, 60);
LineTo(hdc, 5, 5);
DeleteObject(hfont);
ReleaseDC(hwnd,hdc);
getchar();
system("color 07");
system("cls");
ShowTheCursor();
return 0;
}