reapply the changes from rev 4532 (without the resizing issues) and the changes from rev 4555 -- fixes issue 1660

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4578 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
luisr142004 2009-11-15 07:46:43 +00:00
parent 70068a288a
commit 14c3878543
6 changed files with 61 additions and 49 deletions

View file

@ -146,7 +146,8 @@ namespace EmuWindow
{
HWND m_hWnd = NULL; // The new window that is created here
HWND m_hParent = NULL; // The main CPanel
HWND m_hParent = NULL;
HWND m_hMain = NULL; // The main CPanel
HINSTANCE m_hInstance = NULL;
WNDCLASSEX wndClass;
@ -243,16 +244,10 @@ void OnKeyDown(WPARAM wParam)
switch (LOWORD( wParam ))
{
case VK_ESCAPE:
if (g_Config.bFullscreen && !g_Config.RenderToMainframe)
if (!g_Config.RenderToMainframe)
{
// Pressing Esc switch to Windowed in Fullscreen mode
ToggleFullscreen(m_hWnd);
return;
}
else if (!g_Config.RenderToMainframe)
{
// And stops the emulation when already in Windowed mode
PostMessage(m_hParent, WM_USER, OPENGL_WM_USER_STOP, 0);
// Pressing Esc stops the emulation
SendMessage( m_hWnd, WM_CLOSE, 0, 0 );
}
break;
case '3': // OSD keys
@ -275,7 +270,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
switch (iMsg)
{
case WM_CREATE:
PostMessage((HWND)g_VideoInitialize.pWindowHandle, WM_USER, OPENGL_WM_USER_CREATE, (int)m_hParent);
PostMessage(m_hMain, WM_USER, WM_USER_CREATE, g_Config.RenderToMainframe);
break;
case WM_PAINT:
@ -325,7 +320,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
it's nessesary for both the child window and separate rendering window because
moves over the rendering window do not reach the main program then. */
if (GetParentWnd() == NULL) { // Separate rendering window
PostMessage(m_hParent, iMsg, wParam, -1);
PostMessage(m_hMain, iMsg, wParam, -1);
SetCursor(hCursor);
}
else
@ -336,14 +331,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
only let it pass through Dolphin > Frame.cpp to determine if it should be on or off
and coordinate it with the other settings if nessesary */
case WM_USER:
if (wParam == OPENGL_WM_USER_STOP)
if (wParam == WM_USER_STOP)
{
if (lParam)
SetCursor(hCursor);
else
SetCursor(hCursorBlank);
}
if (wParam == OPENGL_WM_USER_KEYDOWN)
if (wParam == WM_USER_KEYDOWN)
OnKeyDown(lParam);
if (wParam == TOGGLE_FULLSCREEN)
ToggleFullscreen(m_hWnd);
@ -353,8 +348,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
case WM_CLOSE:
if (m_hParent == NULL)
{
// Simple hack to easily exit without stopping. Hope to fix the stopping errors soon.
ExitProcess(0);
// Take it out of fullscreen and stop the game
if( g_Config.bFullscreen )
ToggleFullscreen(m_hParent);
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
return 0;
}
@ -405,16 +402,16 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
CreateCursors(m_hInstance);
// Create child window
if (parent)
if (g_Config.RenderToMainframe)
{
m_hParent = parent;
m_hParent = m_hMain = parent;
m_hWnd = CreateWindow(m_szClassName, title,
WS_CHILD,
m_hWnd = CreateWindowEx(0, m_szClassName, title, WS_CHILD,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
parent, NULL, hInstance, NULL);
ShowWindow(m_hWnd, SW_SHOWMAXIMIZED);
/*if( !g_Config.bFullscreen )
SetWindowPos( GetParent(m_hParent), NULL, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER );*/
}
// Create new separate window
@ -424,6 +421,7 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
// render to main, stop, then render to separate window, as the GUI will still
// think we're rendering to main because m_hParent will still contain the old HWND...
m_hParent = NULL;
m_hMain = parent;
DWORD style = g_Config.bFullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW;
@ -438,13 +436,9 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
rc.top = (1024 - h)/2;
rc.bottom = rc.top + h;
m_hWnd = CreateWindow(m_szClassName, title,
style,
m_hWnd = CreateWindowEx(0, m_szClassName, title, style,
rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
parent, NULL, hInstance, NULL );
g_winstyle = GetWindowLong( m_hWnd, GWL_STYLE );
g_winstyle &= ~WS_MAXIMIZE & ~WS_MINIMIZE; // remove minimize/maximize style
NULL, NULL, hInstance, NULL);
}
return m_hWnd;
@ -539,7 +533,9 @@ void Show()
HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title)
{
return OpenWindow(hParent, hInstance, 640, 480, title);
int width=640, height=480;
sscanf( g_Config.bFullscreen ? g_Config.cFSResolution : g_Config.cInternalRes, "%dx%d", &width, &height );
return OpenWindow(hParent, hInstance, width, height, title);
}
void Close()
@ -554,7 +550,8 @@ void Close()
void SetSize(int width, int height)
{
RECT rc = {0, 0, width, height};
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, false);
DWORD dwStyle = GetWindowLong(m_hWnd, GWL_STYLE);
AdjustWindowRect(&rc, dwStyle, false);
int w = rc.right - rc.left;
int h = rc.bottom - rc.top;