void SetWMode(int width, int height, bool state) { #ifndef SHADOW_BROODWAR // Compatibility for Xen W-Mode if ( ghMainWnd && !(GetWindowLong(ghMainWnd, GWL_STYLE) & WS_SYSMENU) ) return; if ( !isCorrectVersion ) return; if ( state ) { wmode = true; if ( !ghMainWnd ) return; // Call the DirectDraw destructor DDrawDestroy(); InitializeWModeBitmap(BW::BWDATA::GameScreenBuffer.width(), BW::BWDATA::GameScreenBuffer.height()); // Hack to enable drawing in Broodwar BW::BWDATA::PrimarySurface = (LPDIRECTDRAWSURFACE)1; const int shift = gdwProcNum > 1 ? 32 : 0; POINT pos = { windowRect.left + shift, windowRect.top + shift }; // Change the window settings SetWindowLong(ghMainWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW); SetWindowPos(ghMainWnd, HWND_NOTOPMOST, pos.x, pos.y, width, height, SWP_SHOWWINDOW); ShowWindow(ghMainWnd, SW_RESTORE); SIZE border; GetBorderSize(ghMainWnd, &border); int w = width + border.cx; int h = height + border.cy; int cx = GetSystemMetrics(SM_CXFULLSCREEN); int cy = GetSystemMetrics(SM_CYFULLSCREEN); while ( pos.x < 0 ) pos.x = 0; while ( pos.y < 0 ) pos.y = 0; if ( pos.y + h >= cy ) { if (gdwProcNum > 1) pos.y -= cy - h; else pos.y = cy - h; } if ( pos.x + w >= cx ) { if (gdwProcNum > 1) pos.x -= cx - w; else pos.x = cx - w; } MoveWindow(ghMainWnd, pos.x, pos.y, w, h, TRUE); SetCursor(NULL); SetCursorShowState(false); SetDIBColorTable(hdcMem, 0, 256, wmodebmp.bmiColors); WriteConfig("window", "windowed", "ON"); } else { wmode = false; BW::BWDATA::PrimarySurface = NULL; if ( hdcMem ) DeleteDC(hdcMem); hdcMem = NULL; if (ghMainWnd) { SetWindowLong(ghMainWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE | WS_SYSMENU); SetWindowPos(ghMainWnd, HWND_TOPMOST, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW); SetCursor(NULL); SetCursorShowState(false); SetFocus(ghMainWnd); } DDrawDestroy(); DDrawInitialize(width, height); WriteConfig("window", "windowed", "OFF"); } #endif }
//------------------------------------------- DIRECT DRAW INIT ----------------------------------------------- void DDInit() { DDrawInitialize(640, 480); }