设置控制台在DEVC++中最大化
可能重复: 我正在写一个简单的破砖程序。当程序启动时,如何最大化控制台窗口设置控制台在DEVC++中最大化,c++,windows,console-application,C++,Windows,Console Application,可能重复: 我正在写一个简单的破砖程序。当程序启动时,如何最大化控制台窗口 #include <iostream> #include <windows.h> #include <algorithm> #include <conio.h> #define _WIN32_WINNT 0x500 using namespace std; int lives = 2; void gotoxy(int x , int y); void hideCursor
#include <iostream>
#include <windows.h>
#include <algorithm>
#include <conio.h>
#define _WIN32_WINNT 0x500
using namespace std;
int lives = 2;
void gotoxy(int x , int y);
void hideCursor();
class Grid
{
public:
char grid[20][79];
void fill()
{
for(int i = 0; i < 20; i++)
{
for(int j = 0; j < 79; j++)
{
grid [i][j] = (char)176;
}
}
}
void print()
{
gotoxy(0,0);
for(int i = 0; i < 20; i++)
{
for(int j = 0; j < 79; j++)
{
cout << grid [i][j];
}
cout << endl;
}
}
};
class Paddle
{
public:
int x_pos;
char paddle[7];
void fill()
{
x_pos = 35;
for (int i = 0; i < 7; i++)
paddle [i] = (char)219;
}
void print()
{
gotoxy (x_pos,23);
for (int j = 0; j < 7; j++)
cout << paddle [j];
}
void redraw()
{
for(int i = 0; i < 80; i++)
{
gotoxy (0+i,23);
cout << " ";
}
print();
}
};
class Ball
{
public:
int x_pos, y_pos;
bool crashed;
char ball;
void create()
{
ball = 'O';
crashed = false;
x_pos = 38;
y_pos = 22;
}
void show()
{
gotoxy (x_pos,y_pos);
cout << ball;
}
};
int main()
{
char move;
Grid grid;
Paddle paddle;
Ball ball;
grid.fill();
paddle.fill();
grid.print();
paddle.print();
ball.create();
ball.show();
hideCursor();
while(!ball.crashed)
{
move = getch();
move = getch();
if(move == 75)
paddle.x_pos--;
else if(move == 77)
paddle.x_pos++;
paddle.redraw();
}
cin.get();
return 0;
}
void hideCursor()
{
HANDLE cmd;
CONSOLE_CURSOR_INFO cur;
char *str = (char*)malloc(32);
cur.dwSize = 1;
cur.bVisible = FALSE;
cmd = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorInfo(cmd, &cur);
}
void gotoxy(int x , int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
使用控制台\全屏\模式标志调用函数
[如果您希望使窗口最大化,但不进入全屏模式,那么这将非常复杂,因为您必须计算在当前屏幕分辨率下,有多少列和行将完全适合屏幕,并考虑窗口设备标题、滚动条和边框的大小。这不是一项简单的任务。请参阅GetSystemMetrics、EnumDisplayMonitors、GetMonitorInfo、SetConsoleScreenBufferSize等]使用CONSOLE全屏模式标志调用函数
HWND hWnd = GetConsoleWindow();
ShowWindow(hWnd,SW_SHOWMAXIMIZED);
[如果您希望使窗口最大化,但不进入全屏模式,那么这将非常复杂,因为您必须计算在当前屏幕分辨率下,有多少列和行将完全适合屏幕,并考虑窗口设备标题、滚动条和边框的大小。这不是一项简单的任务。请参阅GetSystem度量、EnumDisplayMonitors、GetMonitorInfo、SetConsoleScreenBufferSize等]
HWND hWnd = GetConsoleWindow();
ShowWindow(hWnd,SW_SHOWMAXIMIZED);
这适用于我的Dev-C++
这对我来说很有用Dev-C++这不是重复的问题。链接的问题是关于更改控制台窗口中的列数。这是关于进入全屏模式。这不是重复的问题。链接的问题是关于更改控制台窗口中的列数。这是关于进入全屏模式。全屏更好。但是我如何实现它呢?我不熟悉win32 API,所以我自己也写不出来。有任何代码片段。SetConsoleDisplayModeGetStdHandleSTD_OUTPUT_HANDLE,CONSOLE_FULLSCREEN_MODE,NULL;FULLSCREEN_MODE;全屏更适合我。但是我如何实现它呢?我不熟悉win32 API,所以我自己写不出来。有代码吗ets.SetConsoleDisplayModeGetStdHandleSTD_输出_句柄,CONSOLE_全屏_模式,NULL;