2010-01-03 22:18:50 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
2009-09-13 09:23:30 +00:00
|
|
|
#include "VideoConfig.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include "EmuWindow.h"
|
2010-01-03 22:18:50 +00:00
|
|
|
#include "D3DBase.h"
|
2009-03-07 23:34:16 +00:00
|
|
|
#include "Fifo.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2010-01-29 07:44:21 +00:00
|
|
|
|
|
|
|
int OSDChoice = 0 , OSDTime = 0, OSDInternalW = 0, OSDInternalH = 0;
|
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
namespace EmuWindow
|
|
|
|
{
|
2009-04-04 00:45:50 +00:00
|
|
|
HWND m_hWnd = NULL;
|
2009-11-15 07:46:43 +00:00
|
|
|
HWND m_hMain = NULL;
|
2009-04-04 00:45:50 +00:00
|
|
|
HWND m_hParent = NULL;
|
|
|
|
HINSTANCE m_hInstance = NULL;
|
|
|
|
WNDCLASSEX wndClass;
|
2009-09-02 06:33:41 +00:00
|
|
|
const TCHAR m_szClassName[] = _T("DolphinEmuWnd");
|
2009-04-04 00:45:50 +00:00
|
|
|
int g_winstyle;
|
2009-09-13 17:46:33 +00:00
|
|
|
static volatile bool s_sizing;
|
|
|
|
|
2010-01-03 23:05:52 +00:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
/* Invisible cursor option. In the lack of a predefined IDC_BLANK we make
|
|
|
|
an empty transparent cursor */
|
|
|
|
// ------------------
|
|
|
|
HCURSOR hCursor = NULL, hCursorBlank = NULL;
|
|
|
|
void CreateCursors(HINSTANCE hInstance)
|
|
|
|
{
|
|
|
|
BYTE ANDmaskCursor[] = { 0xff };
|
|
|
|
BYTE XORmaskCursor[] = { 0x00 };
|
|
|
|
hCursorBlank = CreateCursor(hInstance, 0,0, 1,1, ANDmaskCursor,XORmaskCursor);
|
|
|
|
|
|
|
|
hCursor = LoadCursor(NULL, IDC_ARROW);
|
|
|
|
}
|
|
|
|
|
2009-09-13 17:46:33 +00:00
|
|
|
bool IsSizing()
|
|
|
|
{
|
|
|
|
return s_sizing;
|
|
|
|
}
|
2009-04-04 00:45:50 +00:00
|
|
|
|
|
|
|
HWND GetWnd()
|
|
|
|
{
|
|
|
|
return m_hWnd;
|
|
|
|
}
|
2009-09-13 17:46:33 +00:00
|
|
|
|
2009-04-04 00:45:50 +00:00
|
|
|
HWND GetParentWnd()
|
|
|
|
{
|
|
|
|
return m_hParent;
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-04-04 00:45:50 +00:00
|
|
|
LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
switch( iMsg )
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-11-15 07:46:43 +00:00
|
|
|
case WM_CREATE:
|
|
|
|
PostMessage( m_hMain, WM_USER, WM_USER_CREATE, g_Config.RenderToMainframe );
|
|
|
|
break;
|
2009-04-04 00:45:50 +00:00
|
|
|
case WM_PAINT:
|
2009-09-13 08:21:35 +00:00
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
hdc = BeginPaint(hWnd, &ps);
|
|
|
|
EndPaint(hWnd, &ps);
|
|
|
|
}
|
2009-04-04 00:45:50 +00:00
|
|
|
return 0;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-09-13 17:46:33 +00:00
|
|
|
case WM_ENTERSIZEMOVE:
|
|
|
|
s_sizing = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_EXITSIZEMOVE:
|
|
|
|
s_sizing = false;
|
|
|
|
break;
|
|
|
|
|
2009-04-04 00:45:50 +00:00
|
|
|
case WM_KEYDOWN:
|
2009-11-15 07:46:43 +00:00
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case VK_ESCAPE:
|
2010-01-03 22:18:50 +00:00
|
|
|
if (g_Config.bFullscreen)
|
2009-12-30 09:00:43 +00:00
|
|
|
{
|
2010-01-03 22:18:50 +00:00
|
|
|
// Pressing Esc switches to Windowed in Fullscreen mode
|
2009-12-30 09:00:43 +00:00
|
|
|
ToggleFullscreen(hWnd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// And stops the emulation when already in Windowed mode
|
|
|
|
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2009-11-15 07:46:43 +00:00
|
|
|
break;
|
2010-01-29 07:44:21 +00:00
|
|
|
case '3': // OSD keys
|
|
|
|
case '4':
|
|
|
|
case '5':
|
|
|
|
case '6':
|
|
|
|
case '7':
|
|
|
|
if (g_Config.bOSDHotKey)
|
|
|
|
OSDMenu(wParam);
|
|
|
|
break;
|
2009-11-15 07:46:43 +00:00
|
|
|
}
|
2009-12-30 15:08:18 +00:00
|
|
|
// Tell the hotkey function that this key was pressed
|
2009-11-15 07:46:43 +00:00
|
|
|
g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
|
|
|
|
break;
|
2010-01-03 22:18:50 +00:00
|
|
|
|
2009-11-15 07:46:43 +00:00
|
|
|
case WM_SYSKEYDOWN:
|
2009-04-04 00:45:50 +00:00
|
|
|
switch( LOWORD( wParam ))
|
|
|
|
{
|
2009-12-30 15:08:18 +00:00
|
|
|
case VK_RETURN: // Pressing Alt+Enter switch FullScreen/Windowed
|
2010-01-04 03:11:31 +00:00
|
|
|
if (m_hParent == NULL && !g_Config.RenderToMainframe)
|
|
|
|
{
|
|
|
|
ToggleFullscreen(hWnd);
|
|
|
|
return 0;
|
|
|
|
}
|
2009-04-04 00:45:50 +00:00
|
|
|
break;
|
2010-01-04 03:31:49 +00:00
|
|
|
case VK_F5: case VK_F6: case VK_F7: case VK_F8:
|
2010-01-04 03:11:31 +00:00
|
|
|
PostMessage(m_hMain, WM_SYSKEYDOWN, wParam, lParam);
|
|
|
|
return 0;
|
2009-04-04 00:45:50 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-09-06 19:30:24 +00:00
|
|
|
/* Post thes mouse events to the main window, it's nessesary because in difference to the
|
|
|
|
keyboard inputs these events only appear here, not in the parent window or any other WndProc()*/
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
PostMessage(GetParentWnd(), iMsg, wParam, lParam);
|
|
|
|
break;
|
|
|
|
|
2009-04-04 00:45:50 +00:00
|
|
|
case WM_CLOSE:
|
2009-12-30 15:08:18 +00:00
|
|
|
// When the user closes the window, we post an event to the main window to call Stop()
|
|
|
|
// Which then handles all the necessary steps to Shutdown the core + the plugins
|
2010-01-01 03:55:39 +00:00
|
|
|
if (m_hParent == NULL)
|
|
|
|
{
|
2010-01-03 23:05:52 +00:00
|
|
|
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
|
2010-01-01 03:55:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
2009-04-04 00:45:50 +00:00
|
|
|
|
2009-10-24 00:18:21 +00:00
|
|
|
case WM_USER:
|
2010-01-03 23:05:52 +00:00
|
|
|
if (wParam == WM_USER_STOP)
|
2010-01-20 07:47:41 +00:00
|
|
|
{
|
2010-01-03 23:05:52 +00:00
|
|
|
SetCursor((lParam) ? hCursor : hCursorBlank);
|
2010-01-20 07:47:41 +00:00
|
|
|
}
|
2010-01-03 23:05:52 +00:00
|
|
|
else if (wParam == TOGGLE_FULLSCREEN)
|
2010-01-20 07:47:41 +00:00
|
|
|
{
|
2010-01-03 22:18:50 +00:00
|
|
|
ToggleFullscreen(hWnd);
|
2010-01-20 07:47:41 +00:00
|
|
|
}
|
2010-01-03 23:05:52 +00:00
|
|
|
else if (wParam == WIIMOTE_DISCONNECT)
|
2010-01-20 07:47:41 +00:00
|
|
|
{
|
2010-01-03 23:05:52 +00:00
|
|
|
PostMessage(m_hMain, WM_USER, wParam, lParam);
|
2010-01-20 07:47:41 +00:00
|
|
|
}
|
2009-04-04 00:45:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SYSCOMMAND:
|
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case SC_SCREENSAVE:
|
|
|
|
case SC_MONITORPOWER:
|
2008-12-08 05:25:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2009-04-04 00:45:50 +00:00
|
|
|
break;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-04-04 00:45:50 +00:00
|
|
|
return DefWindowProc(hWnd, iMsg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2010-01-29 07:44:21 +00:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// OSD Menu
|
|
|
|
// -------------
|
|
|
|
// Let's begin with 3 since 1 and 2 are default Wii keys
|
|
|
|
// -------------
|
|
|
|
void OSDMenu(WPARAM wParam)
|
|
|
|
{
|
|
|
|
switch( LOWORD( wParam ))
|
|
|
|
{
|
|
|
|
case '3':
|
|
|
|
OSDChoice = 1;
|
|
|
|
// Toggle native resolution
|
|
|
|
/*
|
|
|
|
if (!(g_Config.bNativeResolution || g_Config.b2xResolution))
|
|
|
|
g_Config.bNativeResolution = true;
|
|
|
|
else if (g_Config.bNativeResolution && Renderer::AllowCustom())
|
|
|
|
{ g_Config.bNativeResolution = false; if (Renderer::Allow2x()) {g_Config.b2xResolution = true;} }
|
|
|
|
else if (Renderer::AllowCustom())
|
|
|
|
g_Config.b2xResolution = false;
|
|
|
|
*/
|
|
|
|
OSDInternalW = D3D::GetBackBufferWidth();
|
|
|
|
OSDInternalH = D3D::GetBackBufferHeight();
|
|
|
|
break;
|
|
|
|
case '4':
|
|
|
|
OSDChoice = 2;
|
|
|
|
// Toggle aspect ratio
|
|
|
|
g_Config.iAspectRatio = (g_Config.iAspectRatio + 1) & 3;
|
|
|
|
break;
|
|
|
|
case '5':
|
|
|
|
OSDChoice = 3;
|
|
|
|
// Toggle EFB copy
|
|
|
|
if (g_Config.bEFBCopyDisable || g_Config.bCopyEFBToTexture)
|
|
|
|
{
|
|
|
|
g_Config.bEFBCopyDisable = !g_Config.bEFBCopyDisable;
|
|
|
|
g_Config.bCopyEFBToTexture = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_Config.bCopyEFBToTexture = !g_Config.bCopyEFBToTexture;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '6':
|
|
|
|
OSDChoice = 4;
|
|
|
|
g_Config.bDisableFog = !g_Config.bDisableFog;
|
|
|
|
break;
|
|
|
|
case '7':
|
|
|
|
OSDChoice = 5;
|
|
|
|
g_Config.bDisableLighting = !g_Config.bDisableLighting;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-04-04 00:45:50 +00:00
|
|
|
HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const TCHAR *title)
|
|
|
|
{
|
|
|
|
wndClass.cbSize = sizeof( wndClass );
|
2009-09-06 19:30:24 +00:00
|
|
|
wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
|
2009-04-04 00:45:50 +00:00
|
|
|
wndClass.lpfnWndProc = WndProc;
|
|
|
|
wndClass.cbClsExtra = 0;
|
|
|
|
wndClass.cbWndExtra = 0;
|
|
|
|
wndClass.hInstance = hInstance;
|
|
|
|
wndClass.hIcon = LoadIcon( NULL, IDI_APPLICATION );
|
2010-01-04 03:11:31 +00:00
|
|
|
// To interfer less with SetCursor() later we set this to NULL
|
|
|
|
//wndClass.hCursor = LoadCursor( NULL, IDC_ARROW );
|
|
|
|
wndClass.hCursor = NULL;
|
2009-04-04 00:45:50 +00:00
|
|
|
wndClass.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
|
|
|
|
wndClass.lpszMenuName = NULL;
|
|
|
|
wndClass.lpszClassName = m_szClassName;
|
|
|
|
wndClass.hIconSm = LoadIcon( NULL, IDI_APPLICATION );
|
|
|
|
|
|
|
|
m_hInstance = hInstance;
|
|
|
|
RegisterClassEx( &wndClass );
|
|
|
|
|
2010-01-03 23:05:52 +00:00
|
|
|
CreateCursors(m_hInstance);
|
|
|
|
|
2009-10-28 22:40:18 +00:00
|
|
|
if (g_Config.RenderToMainframe)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-11-15 07:46:43 +00:00
|
|
|
m_hParent = m_hMain = parent;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2010-01-20 19:51:13 +00:00
|
|
|
m_hWnd = CreateWindow(m_szClassName, title, WS_CHILD,
|
|
|
|
0, 0, width, height, m_hParent, NULL, hInstance, NULL);
|
2009-04-04 00:45:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-15 07:46:43 +00:00
|
|
|
m_hMain = parent;
|
2010-01-01 03:55:39 +00:00
|
|
|
m_hParent = NULL;
|
2009-11-15 07:46:43 +00:00
|
|
|
|
2010-01-20 07:47:41 +00:00
|
|
|
DWORD style = WS_OVERLAPPEDWINDOW;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-04-04 00:45:50 +00:00
|
|
|
RECT rc = {0, 0, width, height};
|
|
|
|
AdjustWindowRect(&rc, style, false);
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2010-01-20 19:51:13 +00:00
|
|
|
RECT rcdesktop;
|
|
|
|
GetWindowRect(GetDesktopWindow(), &rcdesktop);
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2010-01-20 19:51:13 +00:00
|
|
|
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
|
|
|
|
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2010-01-20 19:51:13 +00:00
|
|
|
m_hWnd = CreateWindow(m_szClassName, title, style,
|
|
|
|
X, Y, rc.right-rc.left, rc.bottom-rc.top,
|
2009-11-15 07:46:43 +00:00
|
|
|
NULL, NULL, hInstance, NULL);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-04-04 00:45:50 +00:00
|
|
|
return m_hWnd;
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-04-04 00:45:50 +00:00
|
|
|
void Show()
|
|
|
|
{
|
2010-01-04 03:11:31 +00:00
|
|
|
ShowWindow(m_hWnd, SW_SHOW);
|
2009-04-04 00:45:50 +00:00
|
|
|
BringWindowToTop(m_hWnd);
|
|
|
|
UpdateWindow(m_hWnd);
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-04-04 00:45:50 +00:00
|
|
|
HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title)
|
|
|
|
{
|
2010-01-19 20:18:41 +00:00
|
|
|
// TODO:
|
|
|
|
// 1. Remove redundant window manipulation,
|
|
|
|
// 2. Make DX9 in fullscreen can be overlapped by other dialogs
|
|
|
|
HWND Ret;
|
2009-10-28 22:40:18 +00:00
|
|
|
int width=640, height=480;
|
2010-01-20 07:47:41 +00:00
|
|
|
sscanf(g_Config.cInternalRes, "%dx%d", &width, &height );
|
|
|
|
|
2010-01-19 20:18:41 +00:00
|
|
|
Ret = OpenWindow(hParent, hInstance, width, height, title);
|
|
|
|
|
|
|
|
if (Ret)
|
|
|
|
{
|
2010-01-20 07:47:41 +00:00
|
|
|
if (g_Config.bFullscreen)
|
|
|
|
ToggleFullscreen(Ret, true);
|
2010-01-19 20:18:41 +00:00
|
|
|
else
|
2010-01-20 07:47:41 +00:00
|
|
|
Show();
|
2010-01-19 20:18:41 +00:00
|
|
|
}
|
|
|
|
return Ret;
|
2009-04-04 00:45:50 +00:00
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-04-04 00:45:50 +00:00
|
|
|
void Close()
|
|
|
|
{
|
2010-01-01 03:55:39 +00:00
|
|
|
if (m_hWnd && !g_Config.RenderToMainframe)
|
|
|
|
{
|
|
|
|
DestroyWindow(m_hWnd);
|
|
|
|
UnregisterClass(m_szClassName, m_hInstance);
|
|
|
|
}
|
2009-04-04 00:45:50 +00:00
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-04-04 00:45:50 +00:00
|
|
|
void SetSize(int width, int height)
|
|
|
|
{
|
|
|
|
RECT rc = {0, 0, width, height};
|
2009-10-28 22:40:18 +00:00
|
|
|
DWORD style = GetWindowLong(m_hWnd, GWL_STYLE);
|
|
|
|
AdjustWindowRect(&rc, style, false);
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-04-04 00:45:50 +00:00
|
|
|
int w = rc.right - rc.left;
|
|
|
|
int h = rc.bottom - rc.top;
|
|
|
|
|
|
|
|
rc.left = (1280 - w)/2;
|
|
|
|
rc.right = rc.left + w;
|
|
|
|
rc.top = (1024 - h)/2;
|
|
|
|
rc.bottom = rc.top + h;
|
2010-01-19 20:18:41 +00:00
|
|
|
MoveWindow(m_hWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE);
|
2009-04-04 00:45:50 +00:00
|
|
|
}
|
2009-09-13 08:21:35 +00:00
|
|
|
|
2010-01-20 07:47:41 +00:00
|
|
|
void ToggleFullscreen(HWND hParent, bool bForceFull)
|
2009-12-30 09:00:43 +00:00
|
|
|
{
|
|
|
|
if (m_hParent == NULL)
|
2010-01-03 22:18:50 +00:00
|
|
|
{
|
2010-01-04 03:11:31 +00:00
|
|
|
if (D3D::IsFullscreen())
|
|
|
|
{
|
2010-01-03 22:18:50 +00:00
|
|
|
PostMessage( m_hMain, WM_USER, WM_USER_STOP, 0 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-30 09:00:43 +00:00
|
|
|
int w_fs = 640, h_fs = 480;
|
2010-01-20 07:47:41 +00:00
|
|
|
if (!g_Config.bFullscreen || bForceFull)
|
2009-12-30 09:00:43 +00:00
|
|
|
{
|
2010-01-03 22:18:50 +00:00
|
|
|
if (strlen(g_Config.cFSResolution) > 1)
|
|
|
|
sscanf(g_Config.cFSResolution, "%dx%d", &w_fs, &h_fs);
|
|
|
|
|
2009-12-30 09:00:43 +00:00
|
|
|
// Get into fullscreen
|
|
|
|
DEVMODE dmScreenSettings;
|
|
|
|
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
|
|
|
|
|
|
|
|
// Desktop -> FullScreen
|
|
|
|
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
|
2010-01-03 22:18:50 +00:00
|
|
|
dmScreenSettings.dmPelsWidth = w_fs;
|
|
|
|
dmScreenSettings.dmPelsHeight = h_fs;
|
|
|
|
dmScreenSettings.dmFields = DM_PELSWIDTH|DM_PELSHEIGHT;
|
2010-01-25 05:12:24 +00:00
|
|
|
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
|
2010-01-03 22:18:50 +00:00
|
|
|
return;
|
2009-12-30 09:00:43 +00:00
|
|
|
|
|
|
|
// Set new window style -> PopUp
|
|
|
|
SetWindowLong(hParent, GWL_STYLE, WS_POPUP);
|
|
|
|
|
2010-01-04 03:11:31 +00:00
|
|
|
// SetWindowPos to the upper-left corner of the screen
|
|
|
|
SetWindowPos(hParent, HWND_TOP, 0, 0, w_fs, h_fs, SWP_NOREPOSITION);
|
|
|
|
|
|
|
|
// Disable the cursor
|
|
|
|
ShowCursor(FALSE);
|
|
|
|
g_Config.bFullscreen = true;
|
|
|
|
|
2010-01-20 07:47:41 +00:00
|
|
|
// Eventually show the window!
|
|
|
|
EmuWindow::Show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (strlen(g_Config.cInternalRes) > 1)
|
|
|
|
sscanf(g_Config.cInternalRes, "%dx%d", &w_fs, &h_fs);
|
|
|
|
|
|
|
|
// FullScreen - > Desktop
|
|
|
|
ChangeDisplaySettings(NULL, 0);
|
|
|
|
|
2010-01-20 19:51:13 +00:00
|
|
|
DWORD style = WS_OVERLAPPEDWINDOW;
|
2010-01-20 07:47:41 +00:00
|
|
|
RECT rc = {0, 0, w_fs, h_fs};
|
2010-01-20 19:51:13 +00:00
|
|
|
AdjustWindowRect(&rc, style, false);
|
|
|
|
RECT rcdesktop;
|
|
|
|
GetWindowRect(GetDesktopWindow(), &rcdesktop);
|
2010-01-20 07:47:41 +00:00
|
|
|
|
2010-01-25 05:12:24 +00:00
|
|
|
// Set new window style FS -> Windowed
|
|
|
|
SetWindowLong(hParent, GWL_STYLE, style);
|
|
|
|
|
2010-01-20 07:47:41 +00:00
|
|
|
// SetWindowPos to the center of the screen
|
|
|
|
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
|
|
|
|
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
|
2010-01-20 19:51:13 +00:00
|
|
|
SetWindowPos(hParent, NULL, X, Y, rc.right-rc.left, rc.bottom-rc.top, SWP_NOREPOSITION | SWP_NOZORDER);
|
2010-01-20 07:47:41 +00:00
|
|
|
|
2010-01-20 19:51:13 +00:00
|
|
|
// Re-Enable the cursor
|
|
|
|
ShowCursor(TRUE);
|
|
|
|
g_Config.bFullscreen = false;
|
2010-01-20 07:47:41 +00:00
|
|
|
|
2009-12-30 09:00:43 +00:00
|
|
|
// Eventually show the window!
|
|
|
|
EmuWindow::Show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|