| 215 | //========================================================================== |
| 216 | |
| 217 | void SystemBaseFrameBuffer::SetWindowSize(int w, int h) |
| 218 | { |
| 219 | if (w < 0 || h < 0) |
| 220 | { |
| 221 | RestoreWindowedPos(); |
| 222 | } |
| 223 | else |
| 224 | { |
| 225 | LONG style = WS_VISIBLE | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW; |
| 226 | LONG exStyle = WS_EX_WINDOWEDGE; |
| 227 | SetWindowLong(mainwindow.GetHandle(), GWL_STYLE, style); |
| 228 | SetWindowLong(mainwindow.GetHandle(), GWL_EXSTYLE, exStyle); |
| 229 | |
| 230 | int winx, winy, winw, winh, scrwidth, scrheight; |
| 231 | |
| 232 | RECT r = { 0, 0, w, h }; |
| 233 | AdjustWindowRectEx(&r, style, false, exStyle); |
| 234 | w = int(r.right - r.left); |
| 235 | h = int(r.bottom - r.top); |
| 236 | |
| 237 | GetCenteredPos(w, h, winx, winy, winw, winh, scrwidth, scrheight); |
| 238 | |
| 239 | // Just move to (0,0) if we were run with the -0 option. |
| 240 | if (Args->CheckParm("-0")) |
| 241 | { |
| 242 | winx = winy = 0; |
| 243 | } |
| 244 | else |
| 245 | { |
| 246 | KeepWindowOnScreen(winx, winy, winw, winh, scrwidth, scrheight); |
| 247 | } |
| 248 | |
| 249 | if (!vid_fullscreen) |
| 250 | { |
| 251 | ShowWindow(mainwindow.GetHandle(), SW_SHOWNORMAL); |
| 252 | SetWindowPos(mainwindow.GetHandle(), nullptr, winx, winy, winw, winh, SWP_NOZORDER | SWP_FRAMECHANGED); |
| 253 | win_maximized = false; |
| 254 | SetSize(GetClientWidth(), GetClientHeight()); |
| 255 | SaveWindowedPos(); |
| 256 | } |
| 257 | else |
| 258 | { |
| 259 | win_x = winx; |
| 260 | win_y = winy; |
| 261 | win_w = winw; |
| 262 | win_h = winh; |
| 263 | win_maximized = false; |
| 264 | vid_fullscreen = false; |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | //========================================================================== |
| 270 | // |