MCPcopy Create free account
hub / github.com/PolygonTek/BlueshiftEngine / ChangeRenderWindow

Function ChangeRenderWindow

Source/Player/WinMain.cpp:86–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86static void ChangeRenderWindow(HWND hwnd, int width, int height, bool fullscreen) {
87 int style = ::GetWindowLong(hwnd, GWL_STYLE);
88
89 if (fullscreen) {
90 style &= ~WS_OVERLAPPEDWINDOW;
91 style |= WS_POPUP;
92 SetWindowLong(hwnd, GWL_STYLE, style);
93 SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_TOPMOST);
94
95 HMENU hmenu = GetMenu(hwnd);
96 if (hmenu) {
97 SetMenu(hwnd, NULL);
98 }
99 } else {
100 style &= ~WS_POPUP;
101 style |= WS_OVERLAPPEDWINDOW;
102 SetWindowLong(hwnd, GWL_STYLE, style);
103 SetWindowLong(hwnd, GWL_EXSTYLE, 0);
104 ShowWindow(hwnd, SW_RESTORE);
105
106 if (hmenu) {
107 SetMenu(hwnd, hmenu);
108 }
109 }
110
111 RECT rect;
112 ::SetRect(&rect, 0, 0, width, height);
113 ::AdjustWindowRect(&rect, style, 0);
114
115 BE1::Rect windowRect;
116 windowRect.w = rect.right - rect.left;
117 windowRect.h = rect.bottom - rect.top;
118
119 if (fullscreen) {
120 windowRect.x = 0;
121 windowRect.y = 0;
122 } else {
123 windowRect.x = (GetSystemMetrics(SM_CXSCREEN) - windowRect.w) >> 1;
124 windowRect.y = (GetSystemMetrics(SM_CYSCREEN) - windowRect.h) >> 1;
125 }
126
127 ::MoveWindow(hwnd, windowRect.x, windowRect.y, windowRect.w, windowRect.h, FALSE);
128
129 ::SetForegroundWindow(hwnd);
130 ::SetFocus(hwnd);
131}
132
133static void DestroyRenderWindow(HWND hwnd) {
134 ::DestroyWindow(hwnd);

Callers 1

ToggleFullscreenFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected