| 570 | } |
| 571 | |
| 572 | void SetWMode(int width, int height, bool state) |
| 573 | { |
| 574 | #ifndef SHADOW_BROODWAR |
| 575 | // Compatibility for Xen W-Mode |
| 576 | if ( ghMainWnd && !(GetWindowLong(ghMainWnd, GWL_STYLE) & WS_SYSMENU) ) |
| 577 | return; |
| 578 | |
| 579 | if ( !isCorrectVersion ) |
| 580 | return; |
| 581 | |
| 582 | if ( state ) |
| 583 | { |
| 584 | wmode = true; |
| 585 | if ( !ghMainWnd ) |
| 586 | return; |
| 587 | |
| 588 | // Call the DirectDraw destructor |
| 589 | DDrawDestroy(); |
| 590 | InitializeWModeBitmap(BW::BWDATA::GameScreenBuffer.width(), BW::BWDATA::GameScreenBuffer.height()); |
| 591 | |
| 592 | // Hack to enable drawing in Broodwar |
| 593 | BW::BWDATA::PrimarySurface = (LPDIRECTDRAWSURFACE)1; |
| 594 | |
| 595 | const int shift = gdwProcNum > 1 ? 32 : 0; |
| 596 | POINT pos = { windowRect.left + shift, windowRect.top + shift }; |
| 597 | // Change the window settings |
| 598 | SetWindowLong(ghMainWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW); |
| 599 | SetWindowPos(ghMainWnd, HWND_NOTOPMOST, pos.x, pos.y, width, height, SWP_SHOWWINDOW); |
| 600 | ShowWindow(ghMainWnd, SW_RESTORE); |
| 601 | |
| 602 | SIZE border; |
| 603 | GetBorderSize(ghMainWnd, &border); |
| 604 | int w = width + border.cx; |
| 605 | int h = height + border.cy; |
| 606 | |
| 607 | int cx = GetSystemMetrics(SM_CXFULLSCREEN); |
| 608 | int cy = GetSystemMetrics(SM_CYFULLSCREEN); |
| 609 | while ( pos.x < 0 ) |
| 610 | pos.x = 0; |
| 611 | while ( pos.y < 0 ) |
| 612 | pos.y = 0; |
| 613 | if ( pos.y + h >= cy ) |
| 614 | { |
| 615 | if (gdwProcNum > 1) |
| 616 | pos.y -= cy - h; |
| 617 | else |
| 618 | pos.y = cy - h; |
| 619 | } |
| 620 | if ( pos.x + w >= cx ) |
| 621 | { |
| 622 | if (gdwProcNum > 1) |
| 623 | pos.x -= cx - w; |
| 624 | else |
| 625 | pos.x = cx - w; |
| 626 | } |
| 627 | MoveWindow(ghMainWnd, pos.x, pos.y, w, h, TRUE); |
| 628 | SetCursor(NULL); |
| 629 | SetCursorShowState(false); |
no test coverage detected