运用C++全屏代码但没有全屏
代码:
#include<windows.h>
#include<iostream>
void FullScreen(HWND hwnd) {
LONG_PTR last_style=GetWindowLongPtr(hwnd,GWL_STYLE);
RECT last_rect;
GetWindowRect(hwnd,&last_rect);
int screen_width=GetSystemMetrics(SM_CXSCREEN);
int screen_height=GetSystemMetrics(SM_CYSCREEN);
SetWindowLongPtr(hwnd,GWL_STYLE,(WS_VISIBLE|WS_POPUP));
SetWindowPos(hwnd,NULL,0,0,screen_width,screen_height,SWP_FRAMECHANGED);
UpdateWindow(hwnd);
}
int main() {
HWND hwnd=GetConsoleWindow();
FullScreen(hwnd);
system("pause");
return 0;
}
结果: