Write their own headers package -windowset.h-1.0

Creative Commons License Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )

windowset.h

//简单窗口设置函数
#ifndef _WINDOWSSET_
#define _WINDOWSSET_
#include<Windows.h>
#include<iostream>
#include <crtdefs.h>
#include <conio.h>
#include "draw.h"
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
//------------
void modeset(int w,int h);	//设置窗口大小
void pause(void);			//无回显暂停
void GetPos(POINT &pt);		//获得当前控制台鼠标坐标 
void color(int a);			//修改当前控制台颜色
void gto(int x,int y);		//设置当前控制台光标到x行y列
//------------
void modeset(int w,int h) {
//	设置窗口大小为 w*h
	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	COORD size = {w, h};
	SetConsoleScreenBufferSize(hOut,size);
	SMALL_RECT rc = {1,1, w, h};
	SetConsoleWindowInfo(hOut ,true ,&rc);
	Sleep(10);
	return;
}
void pause(void) {
	std::cout<<"请按任意键继续. . .";
	getch();
	std::cout<<"\r                      \r";
	return;
}
void GetPos(POINT &pt) {
	HWND hwnd=GetForegroundWindow();
	GetCursorPos(&pt);
	ScreenToClient(hwnd,&pt);
	pt.y=pt.y/16,pt.x=pt.x/8;
}
void color(int a) {
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}
void gto(int x,int y) {
	COORD pos;
	pos.X=y;
	pos.Y=x;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
#endif

A practical header
rely Another write your own header file draw.h
can click on my picture to my article to find

Guess you like

Origin blog.csdn.net/yuanwow/article/details/94206600