2013-05-02 12:17:06 -04:00
# define _WIN32_WINNT 0x0600
2012-12-24 10:20:23 -05:00
# define WIN32_LEAN_AND_MEAN
2013-08-25 12:38:13 -04:00
# define _CRT_SECURE_NO_WARNINGS
2014-05-14 12:39:12 -04:00
# define _CRT_NON_CONFORMING_SWPRINTFS
2013-08-25 12:38:13 -04:00
# include <stdio.h>
2013-10-21 12:38:23 -04:00
# include <stdlib.h>
2012-12-24 10:20:23 -05:00
# include "dxwnd.h"
2013-01-04 10:30:38 -05:00
# include "dxwcore.hpp"
2012-12-24 10:20:23 -05:00
# include "syslibs.h"
2013-07-21 12:38:09 -04:00
# include "dxhook.h"
2012-12-24 10:20:23 -05:00
# include "hddraw.h"
2013-07-21 12:38:09 -04:00
# include "dxhelper.h"
2012-12-24 10:20:23 -05:00
2015-07-04 12:40:35 -04:00
# define FIXCHILDSIZE FALSE
2014-07-13 12:39:33 -04:00
2014-05-14 12:39:12 -04:00
BOOL IsChangeDisplaySettingsHotPatched = FALSE ;
2015-04-26 12:40:41 -04:00
# define GDIMODE_STRETCHED 0
# define GDIMODE_EMULATED 1
# define GDIMODE_DIRECTDRAW 2
int GDIEmulationMode = 0 ;
2014-05-14 12:39:12 -04:00
2014-08-29 12:39:42 -04:00
//typedef BOOL (WINAPI *ValidateRect_Type)(HWND, const RECT *);
//BOOL WINAPI extValidateRect(HWND, const RECT *);
//ValidateRect_Type pValidateRect = NULL;
2015-11-03 11:40:28 -05:00
//typedef BOOL (WINAPI *EnumDisplayMonitors_Type)(HDC, LPCRECT, MONITORENUMPROC, LPARAM);
//EnumDisplayMonitors_Type pEnumDisplayMonitors = NULL;
//BOOL WINAPI extEnumDisplayMonitors(HDC, LPCRECT, MONITORENUMPROC, LPARAM);
2015-07-04 12:40:35 -04:00
typedef BOOL ( WINAPI * BringWindowToTop_Type ) ( HWND ) ;
BringWindowToTop_Type pBringWindowToTop = NULL ;
BOOL WINAPI extBringWindowToTop ( HWND ) ;
typedef BOOL ( WINAPI * SetForegroundWindow_Type ) ( HWND ) ;
SetForegroundWindow_Type pSetForegroundWindow = NULL ;
BOOL WINAPI extSetForegroundWindow ( HWND ) ;
typedef HHOOK ( WINAPI * SetWindowsHookEx_Type ) ( int , HOOKPROC , HINSTANCE , DWORD ) ;
SetWindowsHookEx_Type pSetWindowsHookEx = NULL ;
HHOOK WINAPI extSetWindowsHookEx ( int , HOOKPROC , HINSTANCE , DWORD ) ;
typedef BOOL ( WINAPI * PostMessageA_Type ) ( HWND , UINT , WPARAM , LPARAM ) ;
PostMessageA_Type pPostMessageA = NULL ;
BOOL WINAPI extPostMessageA ( HWND , UINT , WPARAM , LPARAM ) ;
2015-04-18 12:40:38 -04:00
typedef HRESULT ( WINAPI * MessageBoxTimeoutA_Type ) ( HWND , LPCSTR , LPCSTR , UINT , WORD , DWORD ) ;
MessageBoxTimeoutA_Type pMessageBoxTimeoutA = NULL ;
HRESULT WINAPI extMessageBoxTimeoutA ( HWND , LPCSTR , LPCSTR , UINT , WORD , DWORD ) ;
typedef HRESULT ( WINAPI * MessageBoxTimeoutW_Type ) ( HWND , LPCWSTR , LPCWSTR , UINT , WORD , DWORD ) ;
MessageBoxTimeoutW_Type pMessageBoxTimeoutW = NULL ;
HRESULT WINAPI extMessageBoxTimeoutW ( HWND , LPCWSTR , LPCWSTR , UINT , WORD , DWORD ) ;
2015-04-26 12:40:41 -04:00
typedef BOOL ( WINAPI * IsIconic_Type ) ( HWND ) ;
IsIconic_Type pIsIconic = NULL ;
BOOL WINAPI extIsIconic ( HWND ) ;
2015-07-04 12:40:35 -04:00
2015-03-17 12:40:30 -04:00
# ifdef TRACEPALETTE
typedef UINT ( WINAPI * GetDIBColorTable_Type ) ( HDC , UINT , UINT , RGBQUAD * ) ;
GetDIBColorTable_Type pGetDIBColorTable = NULL ;
UINT WINAPI extGetDIBColorTable ( HDC , UINT , UINT , RGBQUAD * ) ;
typedef UINT ( WINAPI * SetDIBColorTable_Type ) ( HDC , UINT , UINT , const RGBQUAD * ) ;
SetDIBColorTable_Type pSetDIBColorTable = NULL ;
UINT WINAPI extSetDIBColorTable ( HDC , UINT , UINT , const RGBQUAD * ) ;
# endif
2015-11-03 11:40:28 -05:00
2013-07-21 12:38:09 -04:00
static HookEntry_Type Hooks [ ] = {
2014-05-14 12:39:12 -04:00
{ HOOK_IAT_CANDIDATE , " UpdateWindow " , ( FARPROC ) NULL , ( FARPROC * ) & pUpdateWindow , ( FARPROC ) extUpdateWindow } ,
//{HOOK_IAT_CANDIDATE, "GetWindowPlacement", (FARPROC)NULL, (FARPROC *)&pGetWindowPlacement, (FARPROC)extGetWindowPlacement},
//{HOOK_IAT_CANDIDATE, "SetWindowPlacement", (FARPROC)NULL, (FARPROC *)&pSetWindowPlacement, (FARPROC)extSetWindowPlacement},
{ HOOK_HOT_CANDIDATE , " ChangeDisplaySettingsA " , ( FARPROC ) ChangeDisplaySettingsA , ( FARPROC * ) & pChangeDisplaySettingsA , ( FARPROC ) extChangeDisplaySettingsA } ,
{ HOOK_HOT_CANDIDATE , " ChangeDisplaySettingsExA " , ( FARPROC ) ChangeDisplaySettingsExA , ( FARPROC * ) & pChangeDisplaySettingsExA , ( FARPROC ) extChangeDisplaySettingsExA } ,
{ HOOK_HOT_CANDIDATE , " ChangeDisplaySettingsW " , ( FARPROC ) NULL , ( FARPROC * ) & pChangeDisplaySettingsW , ( FARPROC ) extChangeDisplaySettingsW } , // ref. by Knights of Honor
{ HOOK_HOT_CANDIDATE , " ChangeDisplaySettingsExW " , ( FARPROC ) NULL , ( FARPROC * ) & pChangeDisplaySettingsExW , ( FARPROC ) extChangeDisplaySettingsExW } ,
2015-03-22 12:40:33 -04:00
{ HOOK_HOT_CANDIDATE , " GetMonitorInfoA " , ( FARPROC ) GetMonitorInfoA , ( FARPROC * ) & pGetMonitorInfoA , ( FARPROC ) extGetMonitorInfoA } ,
{ HOOK_HOT_CANDIDATE , " GetMonitorInfoW " , ( FARPROC ) GetMonitorInfoW , ( FARPROC * ) & pGetMonitorInfoW , ( FARPROC ) extGetMonitorInfoW } ,
2014-05-14 12:39:12 -04:00
{ HOOK_IAT_CANDIDATE , " ShowCursor " , ( FARPROC ) ShowCursor , ( FARPROC * ) & pShowCursor , ( FARPROC ) extShowCursor } ,
{ HOOK_IAT_CANDIDATE , " CreateDialogIndirectParamA " , ( FARPROC ) CreateDialogIndirectParamA , ( FARPROC * ) & pCreateDialogIndirectParam , ( FARPROC ) extCreateDialogIndirectParam } ,
{ HOOK_IAT_CANDIDATE , " CreateDialogParamA " , ( FARPROC ) CreateDialogParamA , ( FARPROC * ) & pCreateDialogParam , ( FARPROC ) extCreateDialogParam } ,
{ HOOK_IAT_CANDIDATE , " MoveWindow " , ( FARPROC ) MoveWindow , ( FARPROC * ) & pMoveWindow , ( FARPROC ) extMoveWindow } ,
{ HOOK_IAT_CANDIDATE , " EnumDisplaySettingsA " , ( FARPROC ) EnumDisplaySettingsA , ( FARPROC * ) & pEnumDisplaySettings , ( FARPROC ) extEnumDisplaySettings } ,
{ HOOK_IAT_CANDIDATE , " GetClipCursor " , ( FARPROC ) GetClipCursor , ( FARPROC * ) & pGetClipCursor , ( FARPROC ) extGetClipCursor } ,
{ HOOK_IAT_CANDIDATE , " ClipCursor " , ( FARPROC ) ClipCursor , ( FARPROC * ) & pClipCursor , ( FARPROC ) extClipCursor } ,
{ HOOK_IAT_CANDIDATE , " DefWindowProcA " , ( FARPROC ) DefWindowProcA , ( FARPROC * ) & pDefWindowProcA , ( FARPROC ) extDefWindowProcA } ,
{ HOOK_IAT_CANDIDATE , " DefWindowProcW " , ( FARPROC ) DefWindowProcW , ( FARPROC * ) & pDefWindowProcW , ( FARPROC ) extDefWindowProcW } ,
{ HOOK_HOT_CANDIDATE , " CreateWindowExA " , ( FARPROC ) CreateWindowExA , ( FARPROC * ) & pCreateWindowExA , ( FARPROC ) extCreateWindowExA } ,
{ HOOK_HOT_CANDIDATE , " CreateWindowExW " , ( FARPROC ) CreateWindowExW , ( FARPROC * ) & pCreateWindowExW , ( FARPROC ) extCreateWindowExW } ,
{ HOOK_IAT_CANDIDATE , " RegisterClassExA " , ( FARPROC ) RegisterClassExA , ( FARPROC * ) & pRegisterClassExA , ( FARPROC ) extRegisterClassExA } ,
{ HOOK_IAT_CANDIDATE , " RegisterClassA " , ( FARPROC ) RegisterClassA , ( FARPROC * ) & pRegisterClassA , ( FARPROC ) extRegisterClassA } ,
2014-10-30 12:39:54 -04:00
{ HOOK_HOT_CANDIDATE , " GetSystemMetrics " , ( FARPROC ) GetSystemMetrics , ( FARPROC * ) & pGetSystemMetrics , ( FARPROC ) extGetSystemMetrics } ,
2015-11-03 11:40:28 -05:00
{ HOOK_HOT_CANDIDATE , " GetDesktopWindow " , ( FARPROC ) GetDesktopWindow , ( FARPROC * ) & pGetDesktopWindow , ( FARPROC ) extGetDesktopWindow } ,
2014-05-14 12:39:12 -04:00
{ HOOK_IAT_CANDIDATE , " CloseWindow " , ( FARPROC ) NULL , ( FARPROC * ) & pCloseWindow , ( FARPROC ) extCloseWindow } ,
{ HOOK_IAT_CANDIDATE , " DestroyWindow " , ( FARPROC ) NULL , ( FARPROC * ) & pDestroyWindow , ( FARPROC ) extDestroyWindow } ,
{ HOOK_IAT_CANDIDATE , " SetSysColors " , ( FARPROC ) NULL , ( FARPROC * ) & pSetSysColors , ( FARPROC ) extSetSysColors } ,
{ HOOK_IAT_CANDIDATE , " SetCapture " , ( FARPROC ) NULL , ( FARPROC * ) & pSetCapture , ( FARPROC ) extSetCapture } ,
2014-08-13 12:39:40 -04:00
{ HOOK_HOT_CANDIDATE , " SetWindowLongA " , ( FARPROC ) SetWindowLongA , ( FARPROC * ) & pSetWindowLongA , ( FARPROC ) extSetWindowLongA } ,
{ HOOK_HOT_CANDIDATE , " GetWindowLongA " , ( FARPROC ) GetWindowLongA , ( FARPROC * ) & pGetWindowLongA , ( FARPROC ) extGetWindowLongA } ,
{ HOOK_HOT_CANDIDATE , " SetWindowLongW " , ( FARPROC ) SetWindowLongW , ( FARPROC * ) & pSetWindowLongW , ( FARPROC ) extSetWindowLongW } ,
{ HOOK_HOT_CANDIDATE , " GetWindowLongW " , ( FARPROC ) GetWindowLongW , ( FARPROC * ) & pGetWindowLongW , ( FARPROC ) extGetWindowLongW } ,
2014-05-14 12:39:12 -04:00
{ HOOK_IAT_CANDIDATE , " IsWindowVisible " , ( FARPROC ) NULL , ( FARPROC * ) & pIsWindowVisible , ( FARPROC ) extIsWindowVisible } ,
2015-07-01 12:40:14 -04:00
// hot by MinHook since v2.03.07
{ HOOK_HOT_CANDIDATE , " SystemParametersInfoA " , ( FARPROC ) SystemParametersInfoA , ( FARPROC * ) & pSystemParametersInfoA , ( FARPROC ) extSystemParametersInfoA } ,
{ HOOK_HOT_CANDIDATE , " SystemParametersInfoW " , ( FARPROC ) SystemParametersInfoW , ( FARPROC * ) & pSystemParametersInfoW , ( FARPROC ) extSystemParametersInfoW } ,
2014-10-30 12:39:54 -04:00
//{HOOK_HOT_CANDIDATE, "GetActiveWindow", (FARPROC)NULL, (FARPROC *)&pGetActiveWindow, (FARPROC)extGetActiveWindow},
2015-01-03 11:40:25 -05:00
//{HOOK_HOT_CANDIDATE, "GetForegroundWindow", (FARPROC)GetForegroundWindow, (FARPROC *)&pGetForegroundWindow, (FARPROC)extGetForegroundWindow},
2014-10-30 12:39:54 -04:00
//{HOOK_IAT_CANDIDATE, "GetWindowTextA", (FARPROC)GetWindowTextA, (FARPROC *)&pGetWindowTextA, (FARPROC)extGetWindowTextA},
2015-11-03 11:40:28 -05:00
//{HOOK_HOT_CANDIDATE, "EnumDisplayMonitors", (FARPROC)EnumDisplayMonitors, (FARPROC *)&pEnumDisplayMonitors, (FARPROC)extEnumDisplayMonitors},
2015-03-17 12:40:30 -04:00
# ifdef TRACEPALETTE
{ HOOK_HOT_CANDIDATE , " GetDIBColorTable " , ( FARPROC ) GetDIBColorTable , ( FARPROC * ) & pGetDIBColorTable , ( FARPROC ) extGetDIBColorTable } ,
{ HOOK_HOT_CANDIDATE , " SetDIBColorTable " , ( FARPROC ) SetDIBColorTable , ( FARPROC * ) & pSetDIBColorTable , ( FARPROC ) extSetDIBColorTable } ,
# endif
2015-07-04 12:40:35 -04:00
{ HOOK_HOT_CANDIDATE , " BringWindowToTop " , ( FARPROC ) BringWindowToTop , ( FARPROC * ) & pBringWindowToTop , ( FARPROC ) extBringWindowToTop } ,
{ HOOK_HOT_CANDIDATE , " SetForegroundWindow " , ( FARPROC ) SetForegroundWindow , ( FARPROC * ) & pSetForegroundWindow , ( FARPROC ) extSetForegroundWindow } ,
{ HOOK_HOT_CANDIDATE , " ChildWindowFromPoint " , ( FARPROC ) ChildWindowFromPoint , ( FARPROC * ) & pChildWindowFromPoint , ( FARPROC ) extChildWindowFromPoint } ,
{ HOOK_HOT_CANDIDATE , " ChildWindowFromPointEx " , ( FARPROC ) ChildWindowFromPointEx , ( FARPROC * ) & pChildWindowFromPointEx , ( FARPROC ) extChildWindowFromPointEx } ,
{ HOOK_HOT_CANDIDATE , " WindowFromPoint " , ( FARPROC ) WindowFromPoint , ( FARPROC * ) & pWindowFromPoint , ( FARPROC ) extWindowFromPoint } ,
{ HOOK_HOT_CANDIDATE , " SetWindowsHookExA " , ( FARPROC ) SetWindowsHookExA , ( FARPROC * ) & pSetWindowsHookEx , ( FARPROC ) extSetWindowsHookEx } ,
2015-04-18 12:40:38 -04:00
//{HOOK_HOT_CANDIDATE, "MessageBoxTimeoutA", (FARPROC)NULL, (FARPROC *)&pMessageBoxTimeoutA, (FARPROC)extMessageBoxTimeoutA},
//{HOOK_HOT_CANDIDATE, "MessageBoxTimeoutW", (FARPROC)NULL, (FARPROC *)&pMessageBoxTimeoutW, (FARPROC)extMessageBoxTimeoutW},
2015-04-26 12:40:41 -04:00
//{HOOK_HOT_CANDIDATE, "IsIconic", (FARPROC)IsIconic, (FARPROC *)&pIsIconic, (FARPROC)extIsIconic},
2014-05-14 12:39:12 -04:00
{ HOOK_IAT_CANDIDATE , 0 , NULL , 0 , 0 } // terminator
2014-11-01 12:38:41 -04:00
} ;
static HookEntry_Type NoGDIHooks [ ] = {
2014-05-14 12:39:12 -04:00
{ HOOK_IAT_CANDIDATE , " BeginPaint " , ( FARPROC ) BeginPaint , ( FARPROC * ) & pBeginPaint , ( FARPROC ) extBeginPaint } ,
{ HOOK_IAT_CANDIDATE , " EndPaint " , ( FARPROC ) EndPaint , ( FARPROC * ) & pEndPaint , ( FARPROC ) extEndPaint } ,
{ HOOK_IAT_CANDIDATE , 0 , NULL , 0 , 0 } // terminator
2013-08-30 12:38:14 -04:00
} ;
static HookEntry_Type EmulateHooks [ ] = {
2015-04-26 12:40:41 -04:00
{ HOOK_IAT_CANDIDATE , " BeginPaint " , ( FARPROC ) BeginPaint , ( FARPROC * ) & pBeginPaint , ( FARPROC ) extBeginPaint } ,
{ HOOK_IAT_CANDIDATE , " EndPaint " , ( FARPROC ) EndPaint , ( FARPROC * ) & pEndPaint , ( FARPROC ) extEndPaint } ,
{ HOOK_IAT_CANDIDATE , " GetDC " , ( FARPROC ) GetDC , ( FARPROC * ) & pGDIGetDC , ( FARPROC ) extGDIGetDC } ,
{ HOOK_IAT_CANDIDATE , " GetDCEx " , ( FARPROC ) GetDCEx , ( FARPROC * ) & pGDIGetDCEx , ( FARPROC ) extGDIGetDCEx } ,
{ HOOK_IAT_CANDIDATE , " GetWindowDC " , ( FARPROC ) GetWindowDC , ( FARPROC * ) & pGDIGetWindowDC , ( FARPROC ) extGDIGetWindowDC } ,
{ HOOK_IAT_CANDIDATE , " ReleaseDC " , ( FARPROC ) ReleaseDC , ( FARPROC * ) & pGDIReleaseDC , ( FARPROC ) extGDIReleaseDC } ,
2014-05-14 12:39:12 -04:00
//{HOOK_IAT_CANDIDATE, "InvalidateRect", (FARPROC)InvalidateRect, (FARPROC *)&pInvalidateRect, (FARPROC)extInvalidateRect},
{ HOOK_IAT_CANDIDATE , 0 , NULL , 0 , 0 } // terminator
2013-07-21 12:38:09 -04:00
} ;
2014-04-01 12:38:40 -04:00
static HookEntry_Type ScaledHooks [ ] = {
2014-05-14 12:39:12 -04:00
{ HOOK_IAT_CANDIDATE , " FrameRect " , ( FARPROC ) NULL , ( FARPROC * ) & pFrameRect , ( FARPROC ) extFrameRect } ,
{ HOOK_IAT_CANDIDATE , " TabbedTextOutA " , ( FARPROC ) TabbedTextOutA , ( FARPROC * ) & pTabbedTextOutA , ( FARPROC ) extTabbedTextOutA } ,
{ HOOK_IAT_CANDIDATE , " DrawTextA " , ( FARPROC ) DrawTextA , ( FARPROC * ) & pDrawText , ( FARPROC ) extDrawTextA } ,
{ HOOK_IAT_CANDIDATE , " DrawTextExA " , ( FARPROC ) DrawTextExA , ( FARPROC * ) & pDrawTextEx , ( FARPROC ) extDrawTextExA } ,
{ HOOK_IAT_CANDIDATE , " FillRect " , ( FARPROC ) NULL , ( FARPROC * ) & pFillRect , ( FARPROC ) extFillRect } ,
{ HOOK_IAT_CANDIDATE , " BeginPaint " , ( FARPROC ) BeginPaint , ( FARPROC * ) & pBeginPaint , ( FARPROC ) extBeginPaint } ,
{ HOOK_IAT_CANDIDATE , " EndPaint " , ( FARPROC ) EndPaint , ( FARPROC * ) & pEndPaint , ( FARPROC ) extEndPaint } ,
{ HOOK_IAT_CANDIDATE , " GetDC " , ( FARPROC ) GetDC , ( FARPROC * ) & pGDIGetDC , ( FARPROC ) extGDIGetDC } ,
{ HOOK_IAT_CANDIDATE , " GetDCEx " , ( FARPROC ) NULL , ( FARPROC * ) & pGDIGetDCEx , ( FARPROC ) extGDIGetDCEx } ,
{ HOOK_IAT_CANDIDATE , " GetWindowDC " , ( FARPROC ) GetWindowDC , ( FARPROC * ) & pGDIGetWindowDC , ( FARPROC ) extGDIGetWindowDC } ,
{ HOOK_IAT_CANDIDATE , " ReleaseDC " , ( FARPROC ) ReleaseDC , ( FARPROC * ) & pGDIReleaseDC , ( FARPROC ) extGDIReleaseDC } ,
{ HOOK_IAT_CANDIDATE , " InvalidateRect " , ( FARPROC ) InvalidateRect , ( FARPROC * ) & pInvalidateRect , ( FARPROC ) extInvalidateRect } ,
2014-08-29 12:39:42 -04:00
//{HOOK_IAT_CANDIDATE, "ValidateRect", (FARPROC)ValidateRect, (FARPROC *)&pValidateRect, (FARPROC)extValidateRect},
2014-05-14 12:39:12 -04:00
{ HOOK_IAT_CANDIDATE , 0 , NULL , 0 , 0 } // terminator
2013-07-21 12:38:09 -04:00
} ;
2015-10-05 12:40:44 -04:00
static HookEntry_Type DDHooks [ ] = {
{ HOOK_IAT_CANDIDATE , " BeginPaint " , ( FARPROC ) BeginPaint , ( FARPROC * ) & pBeginPaint , ( FARPROC ) extDDBeginPaint } ,
//{HOOK_IAT_CANDIDATE, "BeginPaint", (FARPROC)BeginPaint, (FARPROC *)&pBeginPaint, (FARPROC)extBeginPaint},
{ HOOK_IAT_CANDIDATE , " EndPaint " , ( FARPROC ) EndPaint , ( FARPROC * ) & pEndPaint , ( FARPROC ) extDDEndPaint } ,
{ HOOK_IAT_CANDIDATE , " GetDC " , ( FARPROC ) GetDC , ( FARPROC * ) & pGDIGetDC , ( FARPROC ) extDDGetDC } ,
{ HOOK_IAT_CANDIDATE , " GetDCEx " , ( FARPROC ) GetDCEx , ( FARPROC * ) & pGDIGetDCEx , ( FARPROC ) extDDGetDCEx } ,
{ HOOK_IAT_CANDIDATE , " GetWindowDC " , ( FARPROC ) GetWindowDC , ( FARPROC * ) & pGDIGetWindowDC , ( FARPROC ) extDDGetDC } ,
{ HOOK_IAT_CANDIDATE , " ReleaseDC " , ( FARPROC ) ReleaseDC , ( FARPROC * ) & pGDIReleaseDC , ( FARPROC ) extDDReleaseDC } ,
{ HOOK_IAT_CANDIDATE , " InvalidateRect " , ( FARPROC ) InvalidateRect , ( FARPROC * ) & pInvalidateRect , ( FARPROC ) extInvalidateRect } ,
{ HOOK_IAT_CANDIDATE , 0 , NULL , 0 , 0 } // terminator
} ;
2013-07-21 12:38:09 -04:00
static HookEntry_Type RemapHooks [ ] = {
2014-05-14 12:39:12 -04:00
{ HOOK_IAT_CANDIDATE , " ScreenToClient " , ( FARPROC ) ScreenToClient , ( FARPROC * ) & pScreenToClient , ( FARPROC ) extScreenToClient } ,
{ HOOK_IAT_CANDIDATE , " ClientToScreen " , ( FARPROC ) ClientToScreen , ( FARPROC * ) & pClientToScreen , ( FARPROC ) extClientToScreen } ,
{ HOOK_IAT_CANDIDATE , " GetClientRect " , ( FARPROC ) GetClientRect , ( FARPROC * ) & pGetClientRect , ( FARPROC ) extGetClientRect } ,
{ HOOK_IAT_CANDIDATE , " GetWindowRect " , ( FARPROC ) GetWindowRect , ( FARPROC * ) & pGetWindowRect , ( FARPROC ) extGetWindowRect } ,
{ HOOK_IAT_CANDIDATE , " MapWindowPoints " , ( FARPROC ) MapWindowPoints , ( FARPROC * ) & pMapWindowPoints , ( FARPROC ) extMapWindowPoints } ,
2014-07-17 12:39:35 -04:00
{ HOOK_IAT_CANDIDATE , " GetUpdateRgn " , ( FARPROC ) GetUpdateRgn , ( FARPROC * ) & pGetUpdateRgn , ( FARPROC ) extGetUpdateRgn } ,
2014-05-14 12:39:12 -04:00
//{HOOK_IAT_CANDIDATE, "GetUpdateRect", (FARPROC)GetUpdateRect, (FARPROC *)&pGetUpdateRect, (FARPROC)extGetUpdateRect},
2014-07-17 12:39:35 -04:00
//{HOOK_IAT_CANDIDATE, "RedrawWindow", (FARPROC)RedrawWindow, (FARPROC *)&pRedrawWindow, (FARPROC)extRedrawWindow},
2014-05-14 12:39:12 -04:00
{ HOOK_IAT_CANDIDATE , 0 , NULL , 0 , 0 } // terminator
2013-07-21 12:38:09 -04:00
} ;
2013-09-16 12:38:17 -04:00
static HookEntry_Type PeekAllHooks [ ] = {
2014-05-14 12:39:12 -04:00
{ HOOK_IAT_CANDIDATE , " PeekMessageA " , ( FARPROC ) NULL , ( FARPROC * ) & pPeekMessage , ( FARPROC ) extPeekMessage } ,
{ HOOK_IAT_CANDIDATE , " PeekMessageW " , ( FARPROC ) NULL , ( FARPROC * ) & pPeekMessage , ( FARPROC ) extPeekMessage } ,
{ HOOK_IAT_CANDIDATE , 0 , NULL , 0 , 0 } // terminator
2013-07-21 12:38:09 -04:00
} ;
static HookEntry_Type MouseHooks [ ] = {
2014-05-14 12:39:12 -04:00
{ HOOK_IAT_CANDIDATE , " GetCursorPos " , ( FARPROC ) GetCursorPos , ( FARPROC * ) & pGetCursorPos , ( FARPROC ) extGetCursorPos } ,
{ HOOK_IAT_CANDIDATE , " GetCursorInfo " , ( FARPROC ) GetCursorInfo , ( FARPROC * ) & pGetCursorInfo , ( FARPROC ) extGetCursorInfo } ,
{ HOOK_IAT_CANDIDATE , " SetCursor " , ( FARPROC ) SetCursor , ( FARPROC * ) & pSetCursor , ( FARPROC ) extSetCursor } ,
{ HOOK_IAT_CANDIDATE , " SendMessageA " , ( FARPROC ) SendMessageA , ( FARPROC * ) & pSendMessageA , ( FARPROC ) extSendMessageA } ,
{ HOOK_IAT_CANDIDATE , " SendMessageW " , ( FARPROC ) SendMessageW , ( FARPROC * ) & pSendMessageW , ( FARPROC ) extSendMessageW } ,
//{HOOK_IAT_CANDIDATE, "SetPhysicalCursorPos", NULL, (FARPROC *)&pSetCursor, (FARPROC)extSetCursor}, // ???
{ HOOK_IAT_CANDIDATE , 0 , NULL , 0 , 0 } // terminator
2013-07-21 12:38:09 -04:00
} ;
static HookEntry_Type WinHooks [ ] = {
2014-10-06 12:39:20 -04:00
{ HOOK_HOT_CANDIDATE , " ShowWindow " , ( FARPROC ) ShowWindow , ( FARPROC * ) & pShowWindow , ( FARPROC ) extShowWindow } ,
{ HOOK_HOT_CANDIDATE , " SetWindowPos " , ( FARPROC ) SetWindowPos , ( FARPROC * ) & pSetWindowPos , ( FARPROC ) extSetWindowPos } ,
{ HOOK_HOT_CANDIDATE , " DeferWindowPos " , ( FARPROC ) DeferWindowPos , ( FARPROC * ) & pGDIDeferWindowPos , ( FARPROC ) extDeferWindowPos } ,
{ HOOK_HOT_CANDIDATE , " CallWindowProcA " , ( FARPROC ) CallWindowProcA , ( FARPROC * ) & pCallWindowProc , ( FARPROC ) extCallWindowProc } ,
2014-05-14 12:39:12 -04:00
{ HOOK_IAT_CANDIDATE , 0 , NULL , 0 , 0 } // terminator
2013-07-21 12:38:09 -04:00
} ;
static HookEntry_Type MouseHooks2 [ ] = {
2014-05-14 12:39:12 -04:00
{ HOOK_HOT_CANDIDATE , " SetCursorPos " , ( FARPROC ) SetCursorPos , ( FARPROC * ) & pSetCursorPos , ( FARPROC ) extSetCursorPos } ,
{ HOOK_IAT_CANDIDATE , 0 , NULL , 0 , 0 } // terminator
2013-07-21 12:38:09 -04:00
} ;
2014-11-01 12:38:41 -04:00
static HookEntry_Type TimeHooks [ ] = {
2014-05-14 12:39:12 -04:00
{ HOOK_IAT_CANDIDATE , " SetTimer " , ( FARPROC ) SetTimer , ( FARPROC * ) & pSetTimer , ( FARPROC ) extSetTimer } ,
{ HOOK_IAT_CANDIDATE , " KillTimer " , ( FARPROC ) KillTimer , ( FARPROC * ) & pKillTimer , ( FARPROC ) extKillTimer } ,
{ HOOK_IAT_CANDIDATE , 0 , NULL , 0 , 0 } // terminator
2014-11-01 12:38:41 -04:00
} ;
2013-07-21 12:38:09 -04:00
FARPROC Remap_user32_ProcAddress ( LPCSTR proc , HMODULE hModule )
{
FARPROC addr ;
if ( addr = RemapLibrary ( proc , hModule , Hooks ) ) return addr ;
2014-04-01 12:38:40 -04:00
if ( dxw . dwFlags1 & CLIENTREMAPPING ) if ( addr = RemapLibrary ( proc , hModule , RemapHooks ) ) return addr ;
if ( dxw . dwFlags2 & GDISTRETCHED ) if ( addr = RemapLibrary ( proc , hModule , ScaledHooks ) ) return addr ;
if ( dxw . dwFlags3 & GDIEMULATEDC ) if ( addr = RemapLibrary ( proc , hModule , EmulateHooks ) ) return addr ;
if ( dxw . dwFlags1 & MAPGDITOPRIMARY ) if ( addr = RemapLibrary ( proc , hModule , DDHooks ) ) return addr ;
2014-11-01 12:38:41 -04:00
if ( ! ( dxw . dwFlags2 & GDISTRETCHED ) & & ! ( dxw . dwFlags3 & GDIEMULATEDC ) & & ! ( dxw . dwFlags1 & MAPGDITOPRIMARY ) )
if ( addr = RemapLibrary ( proc , hModule , NoGDIHooks ) ) return addr ;
2014-04-01 12:38:40 -04:00
if ( dxw . dwFlags1 & MODIFYMOUSE ) if ( addr = RemapLibrary ( proc , hModule , MouseHooks ) ) return addr ;
2013-07-21 12:38:09 -04:00
if ( dxw . dwFlags1 & ( PREVENTMAXIMIZE | FIXWINFRAME | LOCKWINPOS | LOCKWINSTYLE ) )
if ( addr = RemapLibrary ( proc , hModule , WinHooks ) ) return addr ;
2014-04-01 12:38:40 -04:00
if ( ( dxw . dwFlags1 & ( MODIFYMOUSE | SLOWDOWN | KEEPCURSORWITHIN ) ) | | ( dxw . dwFlags2 & KEEPCURSORFIXED ) )
2013-07-21 12:38:09 -04:00
if ( addr = RemapLibrary ( proc , hModule , MouseHooks2 ) ) return addr ;
2014-04-01 12:38:40 -04:00
if ( dxw . dwFlags3 & PEEKALLMESSAGES )
2013-09-16 12:38:17 -04:00
if ( addr = RemapLibrary ( proc , hModule , PeekAllHooks ) ) return addr ;
2014-02-19 11:38:50 -05:00
if ( ( dxw . dwFlags2 & TIMESTRETCH ) & & ( dxw . dwFlags4 & STRETCHTIMERS ) )
2014-11-01 12:38:41 -04:00
if ( addr = RemapLibrary ( proc , hModule , TimeHooks ) ) return addr ;
2013-07-21 12:38:09 -04:00
return NULL ;
}
static char * libname = " user32.dll " ;
void HookUser32 ( HMODULE hModule )
{
2015-04-26 12:40:41 -04:00
GDIEmulationMode = GDIMODE_STRETCHED ; // default
if ( dxw . dwFlags2 & GDISTRETCHED ) GDIEmulationMode = GDIMODE_STRETCHED ;
if ( dxw . dwFlags3 & GDIEMULATEDC ) GDIEmulationMode = GDIMODE_EMULATED ;
if ( dxw . dwFlags1 & MAPGDITOPRIMARY ) GDIEmulationMode = GDIMODE_DIRECTDRAW ;
2013-07-21 12:38:09 -04:00
HookLibrary ( hModule , Hooks , libname ) ;
2014-11-01 12:38:41 -04:00
if ( ! ( dxw . dwFlags2 & GDISTRETCHED ) & & ! ( dxw . dwFlags3 & GDIEMULATEDC ) & & ! ( dxw . dwFlags1 & MAPGDITOPRIMARY ) )
HookLibrary ( hModule , NoGDIHooks , libname ) ;
2014-04-01 12:38:40 -04:00
if ( dxw . dwFlags3 & GDIEMULATEDC ) HookLibrary ( hModule , EmulateHooks , libname ) ;
if ( dxw . dwFlags2 & GDISTRETCHED ) HookLibrary ( hModule , ScaledHooks , libname ) ;
2013-11-10 11:38:26 -05:00
if ( dxw . dwFlags1 & MAPGDITOPRIMARY ) HookLibrary ( hModule , DDHooks , libname ) ;
2013-07-21 12:38:09 -04:00
if ( dxw . dwFlags1 & CLIENTREMAPPING ) HookLibrary ( hModule , RemapHooks , libname ) ;
2014-11-01 12:38:41 -04:00
if ( dxw . dwFlags1 & MODIFYMOUSE ) HookLibrary ( hModule , MouseHooks , libname ) ;
2014-04-01 12:38:40 -04:00
if ( dxw . dwFlags1 & ( PREVENTMAXIMIZE | FIXWINFRAME | LOCKWINPOS | LOCKWINSTYLE ) ) HookLibrary ( hModule , WinHooks , libname ) ;
2014-11-01 12:38:41 -04:00
if ( ( dxw . dwFlags1 & ( MODIFYMOUSE | SLOWDOWN | KEEPCURSORWITHIN ) ) | | ( dxw . dwFlags2 & KEEPCURSORFIXED ) ) HookLibrary ( hModule , MouseHooks2 , libname ) ;
if ( dxw . dwFlags3 & PEEKALLMESSAGES ) HookLibrary ( hModule , PeekAllHooks , libname ) ;
if ( dxw . dwFlags2 & TIMESTRETCH ) HookLibrary ( hModule , TimeHooks , libname ) ;
2014-04-01 12:38:40 -04:00
2014-05-14 12:39:12 -04:00
IsChangeDisplaySettingsHotPatched = IsHotPatched ( Hooks , " ChangeDisplaySettingsExA " ) | | IsHotPatched ( Hooks , " ChangeDisplaySettingsExW " ) ;
2013-07-21 12:38:09 -04:00
return ;
}
void HookUser32Init ( )
{
HookLibInit ( Hooks ) ;
HookLibInit ( DDHooks ) ;
HookLibInit ( RemapHooks ) ;
HookLibInit ( MouseHooks ) ;
HookLibInit ( WinHooks ) ;
HookLibInit ( MouseHooks2 ) ;
}
2013-11-28 11:38:31 -05:00
/* ------------------------------------------------------------------------------ */
// auxiliary (static) functions
/* ------------------------------------------------------------------------------ */
static void Stopper ( char * s , int line )
{
char sMsg [ 81 ] ;
sprintf ( sMsg , " break: \" %s \" " , s ) ;
MessageBox ( 0 , sMsg , " break " , MB_OK | MB_ICONEXCLAMATION ) ;
}
//#define STOPPER_TEST // comment out to eliminate
# ifdef STOPPER_TEST
# define STOPPER(s) Stopper(s, __LINE__)
# else
# define STOPPER(s)
# endif
2013-07-21 12:38:09 -04:00
// --------------------------------------------------------------------------
//
// globals, externs, static functions...
//
// --------------------------------------------------------------------------
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
// PrimHDC: DC handle of the selected DirectDraw primary surface. NULL when invalid.
HDC PrimHDC = NULL ;
BOOL isWithinDialog = FALSE ;
LPRECT lpClipRegion = NULL ;
RECT ClipRegion ;
int LastCurPosX , LastCurPosY ;
2012-12-24 10:20:23 -05:00
extern GetDC_Type pGetDC ;
extern ReleaseDC_Type pReleaseDC ;
2014-04-01 12:38:40 -04:00
//extern void FixWindowFrame(HWND);
2013-07-21 12:38:09 -04:00
extern HRESULT WINAPI sBlt ( char * , LPDIRECTDRAWSURFACE , LPRECT , LPDIRECTDRAWSURFACE , LPRECT , DWORD , LPDDBLTFX , BOOL ) ;
2012-12-24 10:20:23 -05:00
2013-12-22 11:38:36 -05:00
LONG WINAPI MyChangeDisplaySettings ( char * fname , BOOL WideChar , void * lpDevMode , DWORD dwflags )
{
HRESULT res ;
DWORD dmFields , dmBitsPerPel , dmPelsWidth , dmPelsHeight ;
2014-04-01 12:38:40 -04:00
// v2.02.32: reset the emulated DC used in GDIEMULATEDC mode
2013-12-22 11:38:36 -05:00
dxw . ResetEmulatedDC ( ) ;
if ( lpDevMode ) {
if ( WideChar ) {
dmFields = ( ( DEVMODEW * ) lpDevMode ) - > dmFields ;
dmPelsWidth = ( ( DEVMODEW * ) lpDevMode ) - > dmPelsWidth ;
dmPelsHeight = ( ( DEVMODEW * ) lpDevMode ) - > dmPelsHeight ;
dmBitsPerPel = ( ( DEVMODEW * ) lpDevMode ) - > dmBitsPerPel ;
}
else {
dmFields = ( ( DEVMODEA * ) lpDevMode ) - > dmFields ;
dmPelsWidth = ( ( DEVMODEA * ) lpDevMode ) - > dmPelsWidth ;
dmPelsHeight = ( ( DEVMODEA * ) lpDevMode ) - > dmPelsHeight ;
dmBitsPerPel = ( ( DEVMODEA * ) lpDevMode ) - > dmBitsPerPel ;
}
}
// save desired settings first v.2.1.89
// v2.1.95 protect when lpDevMode is null (closing game... Jedi Outcast)
// v2.2.23 consider new width/height only when dmFields flags are set.
if ( lpDevMode & & ( dmFields & ( DM_PELSWIDTH | DM_PELSHEIGHT ) ) ) {
RECT client ;
dxw . SetScreenSize ( dmPelsWidth , dmPelsHeight ) ;
// v2.02.31: when main win is bigger that expected resolution, you're in windowed fullscreen mode
//(*pGetClientRect)((dxw.dwFlags1 & FIXPARENTWIN) ? dxw.hParentWnd : dxw.GethWnd(), &client);
( * pGetClientRect ) ( dxw . GethWnd ( ) , & client ) ;
OutTraceDW ( " %s: current hWnd=%x size=(%d,%d) \n " , fname , dxw . GethWnd ( ) , client . right , client . bottom ) ;
if ( ( client . right > = ( LONG ) dmPelsWidth ) & & ( client . bottom > = ( LONG ) dmPelsHeight ) ) {
OutTraceDW ( " %s: entering FULLSCREEN mode \n " , fname ) ;
dxw . SetFullScreen ( TRUE ) ;
}
}
2014-10-06 12:39:20 -04:00
2013-12-22 11:38:36 -05:00
if ( ( dwflags = = 0 | | dwflags = = CDS_FULLSCREEN ) & & lpDevMode ) {
if ( dxw . dwFlags1 & EMULATESURFACE | | ! ( dmFields & DM_BITSPERPEL ) ) {
OutTraceDW ( " %s: BYPASS res=DISP_CHANGE_SUCCESSFUL \n " , fname ) ;
return DISP_CHANGE_SUCCESSFUL ;
}
else {
DEVMODEA NewMode ;
if ( dwflags = = CDS_FULLSCREEN ) dwflags = 0 ; // no FULLSCREEN
2014-10-06 12:39:20 -04:00
( * pEnumDisplaySettings ) ( NULL , ENUM_CURRENT_SETTINGS , & NewMode ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " ChangeDisplaySettings: CURRENT wxh=(%dx%d) BitsPerPel=%d -> %d \n " ,
NewMode . dmPelsWidth , NewMode . dmPelsHeight , NewMode . dmBitsPerPel , dmBitsPerPel ) ;
NewMode . dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT ;
NewMode . dmBitsPerPel = dmBitsPerPel ;
2014-05-14 12:39:12 -04:00
res = ( * pChangeDisplaySettingsExA ) ( NULL , & NewMode , NULL , 0 , NULL ) ;
2013-12-22 11:38:36 -05:00
if ( res ) OutTraceE ( " ChangeDisplaySettings: ERROR err=%d at %d \n " , GetLastError ( ) , __LINE__ ) ;
return res ;
}
}
else {
if ( WideChar )
2014-10-06 12:39:20 -04:00
return ( * pChangeDisplaySettingsExW ) ( NULL , ( LPDEVMODEW ) lpDevMode , NULL , dwflags , NULL ) ;
2013-12-22 11:38:36 -05:00
else
2014-05-14 12:39:12 -04:00
return ( * pChangeDisplaySettingsExA ) ( NULL , ( LPDEVMODEA ) lpDevMode , NULL , dwflags , NULL ) ;
2013-12-22 11:38:36 -05:00
}
}
2013-07-21 12:38:09 -04:00
void dxwFixWindowPos ( char * ApiName , HWND hwnd , LPARAM lParam )
{
LPWINDOWPOS wp ;
int MaxX , MaxY ;
wp = ( LPWINDOWPOS ) lParam ;
MaxX = dxw . iSizX ;
MaxY = dxw . iSizY ;
if ( ! MaxX ) MaxX = dxw . GetScreenWidth ( ) ;
if ( ! MaxY ) MaxY = dxw . GetScreenHeight ( ) ;
static int iLastCX , iLastCY ;
static int BorderX = - 1 ;
static int BorderY = - 1 ;
int cx , cy ;
2014-11-01 12:38:41 -04:00
extern void CalculateWindowPos ( HWND , DWORD , DWORD , LPWINDOWPOS ) ;
2013-07-21 12:38:09 -04:00
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: GOT hwnd=%x pos=(%d,%d) dim=(%d,%d) Flags=%x(%s) \n " ,
2013-07-21 12:38:09 -04:00
ApiName , hwnd , wp - > x , wp - > y , wp - > cx , wp - > cy , wp - > flags , ExplainWPFlags ( wp - > flags ) ) ;
2013-08-30 12:38:14 -04:00
if ( dxw . dwFlags1 & PREVENTMAXIMIZE ) {
int UpdFlag = 0 ;
2014-11-01 12:38:41 -04:00
WINDOWPOS MaxPos ;
CalculateWindowPos ( hwnd , MaxX , MaxY , & MaxPos ) ;
2013-08-30 12:38:14 -04:00
2014-11-01 12:38:41 -04:00
if ( wp - > cx > MaxPos . cx ) { wp - > cx = MaxPos . cx ; UpdFlag = 1 ; }
if ( wp - > cy > MaxPos . cy ) { wp - > cy = MaxPos . cy ; UpdFlag = 1 ; }
2013-08-30 12:38:14 -04:00
if ( UpdFlag )
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: SET max dim=(%d,%d) \n " , ApiName , wp - > cx , wp - > cy ) ;
2013-08-30 12:38:14 -04:00
}
2013-07-21 12:38:09 -04:00
if ( ( wp - > flags & ( SWP_NOMOVE | SWP_NOSIZE ) ) = = ( SWP_NOMOVE | SWP_NOSIZE ) ) return ; //v2.02.13
if ( ( dxw . dwFlags1 & LOCKWINPOS ) & & dxw . IsFullScreen ( ) & & ( hwnd = = dxw . GethWnd ( ) ) ) {
CalculateWindowPos ( hwnd , MaxX , MaxY , wp ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: LOCK pos=(%d,%d) dim=(%d,%d) \n " , ApiName , wp - > x , wp - > y , wp - > cx , wp - > cy ) ;
2013-07-21 12:38:09 -04:00
}
if ( ( dxw . dwFlags2 & KEEPASPECTRATIO ) & & dxw . IsFullScreen ( ) & & ( hwnd = = dxw . GethWnd ( ) ) ) {
// note: while keeping aspect ration, resizing from one corner doesn't tell
// which coordinate is prevalent to the other. We made an arbitrary choice.
// note: v2.1.93: compensation must refer to the client area, not the wp
// window dimensions that include the window borders.
if ( BorderX = = - 1 ) {
2014-09-20 12:39:46 -04:00
// v2.02.92: Fixed for AERO mode, where GetWindowRect substantially LIES!
RECT client , full ;
LONG dwStyle , dwExStyle ;
HMENU hMenu ;
extern GetWindowLong_Type pGetWindowLongA ;
( * pGetClientRect ) ( hwnd , & client ) ;
full = client ;
dwStyle = ( * pGetWindowLongA ) ( hwnd , GWL_STYLE ) ;
dwExStyle = ( * pGetWindowLongA ) ( hwnd , GWL_EXSTYLE ) ;
hMenu = ( dwStyle & WS_CHILD ) ? NULL : GetMenu ( hwnd ) ;
AdjustWindowRectEx ( & full , dwStyle , ( hMenu ! = NULL ) , dwExStyle ) ;
2015-07-04 12:40:35 -04:00
if ( hMenu & & ( hMenu ! = ( HMENU ) - 1 ) ) __try { CloseHandle ( hMenu ) ; } __except ( EXCEPTION_EXECUTE_HANDLER ) { } ;
2014-09-20 12:39:46 -04:00
BorderX = full . right - full . left - client . right ;
BorderY = full . bottom - full . top - client . bottom ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: KEEPASPECTRATIO window borders=(%d,%d) \n " , ApiName , BorderX , BorderY ) ;
2013-07-21 12:38:09 -04:00
}
extern LRESULT LastCursorPos ;
switch ( LastCursorPos ) {
case HTBOTTOM :
case HTTOP :
case HTBOTTOMLEFT :
case HTBOTTOMRIGHT :
case HTTOPLEFT :
case HTTOPRIGHT :
2014-08-10 12:39:50 -04:00
cx = BorderX + ( ( wp - > cy - BorderY ) * dxw . iRatioX ) / dxw . iRatioY ;
2013-07-21 12:38:09 -04:00
if ( cx ! = wp - > cx ) {
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: KEEPASPECTRATIO adjusted cx=%d->%d \n " , ApiName , wp - > cx , cx ) ;
2013-07-21 12:38:09 -04:00
wp - > cx = cx ;
}
break ;
case HTLEFT :
case HTRIGHT :
2014-08-10 12:39:50 -04:00
cy = BorderY + ( ( wp - > cx - BorderX ) * dxw . iRatioY ) / dxw . iRatioX ;
2013-07-21 12:38:09 -04:00
if ( cy ! = wp - > cy ) {
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: KEEPASPECTRATIO adjusted cy=%d->%d \n " , ApiName , wp - > cy , cy ) ;
2013-07-21 12:38:09 -04:00
wp - > cy = cy ;
}
break ;
}
}
2015-01-24 11:40:16 -05:00
if ( ( dxw . dwFlags5 & CENTERTOWIN ) & & dxw . IsFullScreen ( ) & & ( hwnd = = dxw . GethWnd ( ) ) ) {
RECT wrect ;
LONG dwStyle , dwExStyle ;
HMENU hMenu ;
int minx , miny ;
2015-02-15 11:40:23 -05:00
wrect = dxw . GetScreenRect ( ) ;
2015-01-24 11:40:16 -05:00
dwStyle = ( * pGetWindowLongA ) ( hwnd , GWL_STYLE ) ;
dwExStyle = ( * pGetWindowLongA ) ( hwnd , GWL_EXSTYLE ) ;
hMenu = ( dwStyle & WS_CHILD ) ? NULL : GetMenu ( hwnd ) ;
AdjustWindowRectEx ( & wrect , dwStyle , ( hMenu ! = NULL ) , dwExStyle ) ;
minx = wrect . right - wrect . left ;
miny = wrect . bottom - wrect . top ;
if ( wp - > cx < minx ) wp - > cx = minx ;
if ( wp - > cy < miny ) wp - > cy = miny ;
}
2013-07-21 12:38:09 -04:00
iLastCX = wp - > cx ;
iLastCY = wp - > cy ;
}
void dxwFixMinMaxInfo ( char * ApiName , HWND hwnd , LPARAM lParam )
{
if ( dxw . dwFlags1 & PREVENTMAXIMIZE ) {
LPMINMAXINFO lpmmi ;
lpmmi = ( LPMINMAXINFO ) lParam ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: GOT MaxPosition=(%d,%d) MaxSize=(%d,%d) \n " , ApiName ,
2013-07-21 12:38:09 -04:00
lpmmi - > ptMaxPosition . x , lpmmi - > ptMaxPosition . y , lpmmi - > ptMaxSize . x , lpmmi - > ptMaxSize . y ) ;
lpmmi - > ptMaxPosition . x = 0 ;
lpmmi - > ptMaxPosition . y = 0 ;
2015-07-01 12:40:14 -04:00
lpmmi - > ptMaxSize . x = dxw . GetScreenWidth ( ) ;
lpmmi - > ptMaxSize . y = dxw . GetScreenHeight ( ) ;
2014-11-01 12:38:41 -04:00
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: SET PREVENTMAXIMIZE MaxPosition=(%d,%d) MaxSize=(%d,%d) \n " , ApiName ,
2013-07-21 12:38:09 -04:00
lpmmi - > ptMaxPosition . x , lpmmi - > ptMaxPosition . y , lpmmi - > ptMaxSize . x , lpmmi - > ptMaxSize . y ) ;
}
2014-11-01 12:38:41 -04:00
2013-07-21 12:38:09 -04:00
// v2.1.75: added logic to fix win coordinates to selected ones.
// fixes the problem with "Achtung Spitfire", that can't be managed through PREVENTMAXIMIZE flag.
if ( dxw . dwFlags1 & LOCKWINPOS ) {
LPMINMAXINFO lpmmi ;
lpmmi = ( LPMINMAXINFO ) lParam ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: GOT MaxPosition=(%d,%d) MaxSize=(%d,%d) \n " , ApiName ,
2013-07-21 12:38:09 -04:00
lpmmi - > ptMaxPosition . x , lpmmi - > ptMaxPosition . y , lpmmi - > ptMaxSize . x , lpmmi - > ptMaxSize . y ) ;
lpmmi - > ptMaxPosition . x = dxw . iPosX ;
lpmmi - > ptMaxPosition . y = dxw . iPosY ;
lpmmi - > ptMaxSize . x = dxw . iSizX ? dxw . iSizX : dxw . GetScreenWidth ( ) ;
lpmmi - > ptMaxSize . y = dxw . iSizY ? dxw . iSizY : dxw . GetScreenHeight ( ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: SET LOCKWINPOS MaxPosition=(%d,%d) MaxSize=(%d,%d) \n " , ApiName ,
2013-07-21 12:38:09 -04:00
lpmmi - > ptMaxPosition . x , lpmmi - > ptMaxPosition . y , lpmmi - > ptMaxSize . x , lpmmi - > ptMaxSize . y ) ;
}
}
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
static LRESULT WINAPI FixWindowProc ( char * ApiName , HWND hwnd , UINT Msg , WPARAM wParam , LPARAM * lpParam )
{
LPARAM lParam ;
lParam = * lpParam ;
OutTraceW ( " %s: hwnd=%x msg=[0x%x]%s(%x,%x) \n " ,
ApiName , hwnd , Msg , ExplainWinMessage ( Msg ) , wParam , lParam ) ;
switch ( Msg ) {
2014-04-22 12:39:07 -04:00
case WM_NCHITTEST :
// v2.02.71 fix: when processing WM_NCHITTEST messages whith fixed coordinates avoid calling
// the *pDefWindowProc call
// fixes "Microsoft Motocross Madness" mouse handling
if ( ( dxw . dwFlags2 & FIXNCHITTEST ) & & ( dxw . dwFlags1 & MODIFYMOUSE ) ) { // mouse processing
OutTraceDW ( " %s: suppress WM_NCHITTEST \n " , ApiName ) ;
return TRUE ;
}
break ;
2013-07-21 12:38:09 -04:00
case WM_ERASEBKGND :
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: prevent erase background \n " , ApiName ) ;
2014-04-22 12:39:07 -04:00
return TRUE ; // 1=erased
2013-07-21 12:38:09 -04:00
break ; // useless
case WM_GETMINMAXINFO :
dxwFixMinMaxInfo ( ApiName , hwnd , lParam ) ;
break ;
case WM_WINDOWPOSCHANGING :
case WM_WINDOWPOSCHANGED :
dxwFixWindowPos ( ApiName , hwnd , lParam ) ;
break ;
case WM_STYLECHANGING :
case WM_STYLECHANGED :
dxw . FixStyle ( ApiName , hwnd , wParam , lParam ) ;
break ;
case WM_SIZE :
if ( ( dxw . dwFlags1 & LOCKWINPOS ) & & dxw . IsFullScreen ( ) ) return 0 ;
if ( dxw . dwFlags1 & PREVENTMAXIMIZE ) {
if ( ( wParam = = SIZE_MAXIMIZED ) | | ( wParam = = SIZE_MAXSHOW ) ) {
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: prevent screen SIZE to fullscreen wparam=%d(%s) size=(%d,%d) \n " , ApiName ,
2013-07-21 12:38:09 -04:00
wParam , ExplainResizing ( wParam ) , HIWORD ( lParam ) , LOWORD ( lParam ) ) ;
return 0 ; // checked
//lParam = MAKELPARAM(dxw.GetScreenWidth(), dxw.GetScreenHeight());
2013-12-22 11:38:36 -05:00
//OutTraceDW("%s: updated SIZE wparam=%d(%s) size=(%d,%d)\n", ApiName,
2013-07-21 12:38:09 -04:00
// wParam, ExplainResizing(wParam), HIWORD(lParam), LOWORD(lParam));
}
}
break ;
default :
break ;
}
2014-08-29 12:39:42 -04:00
2013-07-21 12:38:09 -04:00
// marker to run hooked function
return ( - 1 ) ;
}
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
// --------------------------------------------------------------------------
//
// user32 API hookers
//
// --------------------------------------------------------------------------
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
BOOL WINAPI extInvalidateRect ( HWND hwnd , RECT * lpRect , BOOL bErase )
{
if ( lpRect )
2013-12-22 11:38:36 -05:00
OutTraceDW ( " InvalidateRect: hwnd=%x rect=(%d,%d)-(%d,%d) erase=%x \n " ,
2013-07-21 12:38:09 -04:00
hwnd , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom , bErase ) ;
else
2013-12-22 11:38:36 -05:00
OutTraceDW ( " InvalidateRect: hwnd=%x rect=NULL erase=%x \n " ,
2013-07-21 12:38:09 -04:00
hwnd , bErase ) ;
2012-12-24 10:20:23 -05:00
2014-04-01 12:38:40 -04:00
if ( dxw . IsFullScreen ( ) & & dxw . IsRealDesktop ( hwnd ) ) {
hwnd = dxw . GethWnd ( ) ;
dxw . MapClient ( lpRect ) ;
return ( * pInvalidateRect ) ( hwnd , lpRect , bErase ) ;
}
else {
// just exagerate ...
return ( * pInvalidateRect ) ( hwnd , NULL , bErase ) ;
}
2013-07-21 12:38:09 -04:00
}
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
BOOL WINAPI extShowWindow ( HWND hwnd , int nCmdShow )
{
BOOL res ;
2012-12-24 10:20:23 -05:00
2013-12-22 11:38:36 -05:00
OutTraceDW ( " ShowWindow: hwnd=%x, CmdShow=%x(%s) \n " , hwnd , nCmdShow , ExplainShowCmd ( nCmdShow ) ) ;
2013-07-21 12:38:09 -04:00
if ( dxw . dwFlags1 & PREVENTMAXIMIZE ) {
if ( nCmdShow = = SW_MAXIMIZE ) {
2014-04-01 12:38:40 -04:00
OutTraceDW ( " ShowWindow: suppress SW_MAXIMIZE maximize \n " ) ;
2013-07-21 12:38:09 -04:00
nCmdShow = SW_SHOWNORMAL ;
2012-12-24 10:20:23 -05:00
}
2014-04-01 12:38:40 -04:00
if ( nCmdShow = = SW_SHOWDEFAULT ) {
STARTUPINFO StartupInfo ;
GetStartupInfo ( & StartupInfo ) ;
OutTraceDW ( " DEBUG: StartupInfo dwFlags=%x ShowWindow=%x \n " , StartupInfo . dwFlags , StartupInfo . wShowWindow ) ;
if ( ( StartupInfo . dwFlags & STARTF_USESHOWWINDOW ) & & ( StartupInfo . wShowWindow = = SW_MAXIMIZE ) ) {
OutTraceDW ( " ShowWindow: suppress SW_SHOWDEFAULT maximize \n " ) ;
nCmdShow = SW_SHOWNORMAL ;
}
}
2014-01-24 11:38:44 -05:00
}
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
res = ( * pShowWindow ) ( hwnd , nCmdShow ) ;
2014-04-12 12:40:05 -04:00
OutTraceDW ( " ShowWindow: res=%x \n " , res ) ;
2012-12-24 10:20:23 -05:00
return res ;
}
2014-08-29 12:39:42 -04:00
LONG WINAPI extGetWindowLong ( GetWindowLong_Type pGetWindowLong , char * ApiName , HWND hwnd , int nIndex )
2012-12-24 10:20:23 -05:00
{
LONG res ;
2014-08-29 12:39:42 -04:00
res = ( * pGetWindowLong ) ( hwnd , nIndex ) ;
2012-12-24 10:20:23 -05:00
2014-08-29 12:39:42 -04:00
OutTraceDW ( " %s: hwnd=%x, Index=%x(%s) res=%x \n " , ApiName , hwnd , nIndex , ExplainSetWindowIndex ( nIndex ) , res ) ;
2012-12-24 10:20:23 -05:00
2014-10-06 12:39:20 -04:00
if ( ( nIndex = = GWL_WNDPROC ) | | ( nIndex = = DWL_DLGPROC ) ) {
2012-12-24 10:20:23 -05:00
WNDPROC wp ;
2014-07-13 12:39:33 -04:00
wp = WinDBGetProc ( hwnd ) ;
2014-08-29 12:39:42 -04:00
OutTraceDW ( " %s: remapping WindowProc res=%x -> %x \n " , ApiName , res , ( LONG ) wp ) ;
2012-12-24 10:20:23 -05:00
if ( wp ) res = ( LONG ) wp ; // if not found, don't alter the value.
}
return res ;
}
2014-04-22 12:39:07 -04:00
LONG WINAPI extGetWindowLongA ( HWND hwnd , int nIndex )
{
2014-08-29 12:39:42 -04:00
return extGetWindowLong ( pGetWindowLongA , " GetWindowLongA " , hwnd , nIndex ) ;
2014-04-22 12:39:07 -04:00
}
LONG WINAPI extGetWindowLongW ( HWND hwnd , int nIndex )
{
2014-08-29 12:39:42 -04:00
return extGetWindowLong ( pGetWindowLongW , " GetWindowLongW " , hwnd , nIndex ) ;
2014-04-22 12:39:07 -04:00
}
LONG WINAPI extSetWindowLong ( HWND hwnd , int nIndex , LONG dwNewLong , SetWindowLong_Type pSetWindowLong )
2012-12-24 10:20:23 -05:00
{
LONG res ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " SetWindowLong: hwnd=%x, Index=%x(%s) Val=%x \n " ,
2012-12-24 10:20:23 -05:00
hwnd , nIndex , ExplainSetWindowIndex ( nIndex ) , dwNewLong ) ;
2014-02-05 11:39:10 -05:00
if ( dxw . Windowize ) {
if ( dxw . dwFlags1 & LOCKWINSTYLE ) {
if ( nIndex = = GWL_STYLE ) {
OutTraceDW ( " SetWindowLong: Lock GWL_STYLE=%x \n " , dwNewLong ) ;
return ( * pGetWindowLongA ) ( hwnd , nIndex ) ;
}
if ( nIndex = = GWL_EXSTYLE ) {
OutTraceDW ( " SetWindowLong: Lock GWL_EXSTYLE=%x \n " , dwNewLong ) ;
return ( * pGetWindowLongA ) ( hwnd , nIndex ) ;
}
2012-12-24 10:20:23 -05:00
}
2014-02-05 11:39:10 -05:00
if ( dxw . dwFlags1 & PREVENTMAXIMIZE ) {
if ( nIndex = = GWL_STYLE ) {
dwNewLong & = ~ WS_MAXIMIZE ;
if ( dxw . IsDesktop ( hwnd ) ) {
OutTraceDW ( " SetWindowLong: GWL_STYLE %x suppress MAXIMIZE \n " , dwNewLong ) ;
dwNewLong | = WS_OVERLAPPEDWINDOW ;
dwNewLong & = ~ ( WS_DLGFRAME | WS_MAXIMIZE | WS_VSCROLL | WS_HSCROLL | WS_CLIPSIBLINGS ) ;
}
}
// v2.02.32: disable topmost for main window only
if ( dxw . IsDesktop ( hwnd ) & & ( nIndex = = GWL_EXSTYLE ) ) {
OutTraceDW ( " SetWindowLong: GWL_EXSTYLE %x suppress TOPMOST \n " , dwNewLong ) ;
dwNewLong = dwNewLong & ~ ( WS_EX_TOPMOST ) ;
2013-08-30 12:38:14 -04:00
}
2012-12-24 10:20:23 -05:00
}
2014-02-05 11:39:10 -05:00
if ( dxw . dwFlags1 & FIXWINFRAME ) {
//if((nIndex==GWL_STYLE) && !(dwNewLong & WS_CHILD)){
if ( ( nIndex = = GWL_STYLE ) & & ! ( dwNewLong & WS_CHILD ) & & dxw . IsDesktop ( hwnd ) ) {
OutTraceDW ( " SetWindowLong: GWL_STYLE %x force OVERLAPPEDWINDOW \n " , dwNewLong ) ;
dwNewLong | = WS_OVERLAPPEDWINDOW ;
dwNewLong & = ~ WS_CLIPSIBLINGS ;
}
2012-12-24 10:20:23 -05:00
}
}
2014-10-06 12:39:20 -04:00
if ( ( ( nIndex = = GWL_WNDPROC ) | | ( nIndex = = DWL_DLGPROC ) ) & & dxw . IsFullScreen ( ) ) { // v2.02.51 - see A10 Cuba....
2013-10-08 12:38:12 -04:00
WNDPROC lres ;
WNDPROC OldProc ;
2013-04-04 12:17:08 -04:00
// GPL fix
2014-06-07 12:39:29 -04:00
if ( dxw . IsRealDesktop ( hwnd ) & & dxw . Windowize ) {
2013-04-04 12:17:08 -04:00
hwnd = dxw . GethWnd ( ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " SetWindowLong: DESKTOP hwnd, FIXING hwnd=%x \n " , hwnd ) ;
2013-04-04 12:17:08 -04:00
}
// end of GPL fix
2013-10-08 12:38:12 -04:00
2014-10-06 12:39:20 -04:00
OldProc = ( WNDPROC ) ( * pGetWindowLongA ) ( hwnd , nIndex ) ;
2014-04-13 12:39:06 -04:00
// v2.02.70 fix
if ( ( OldProc = = extWindowProc ) | |
( OldProc = = extChildWindowProc ) | |
( OldProc = = extDialogWindowProc ) )
2014-07-13 12:39:33 -04:00
OldProc = WinDBGetProc ( hwnd ) ;
WinDBPutProc ( hwnd , ( WNDPROC ) dwNewLong ) ;
2013-10-08 12:38:12 -04:00
res = ( LONG ) OldProc ;
2012-12-24 10:20:23 -05:00
SetLastError ( 0 ) ;
2014-10-06 12:39:20 -04:00
lres = ( WNDPROC ) ( * pSetWindowLongA ) ( hwnd , nIndex , ( LONG ) extWindowProc ) ;
2012-12-24 10:20:23 -05:00
if ( ! lres & & GetLastError ( ) ) OutTraceE ( " SetWindowLong: ERROR err=%d at %d \n " , GetLastError ( ) , __LINE__ ) ;
}
else {
2014-04-22 12:39:07 -04:00
res = ( * pSetWindowLongA ) ( hwnd , nIndex , dwNewLong ) ;
2012-12-24 10:20:23 -05:00
}
2013-12-22 11:38:36 -05:00
OutTraceDW ( " SetWindowLong: hwnd=%x, nIndex=%x, Val=%x, res=%x \n " , hwnd , nIndex , dwNewLong , res ) ;
2012-12-24 10:20:23 -05:00
return res ;
}
2014-04-22 12:39:07 -04:00
LONG WINAPI extSetWindowLongA ( HWND hwnd , int nIndex , LONG dwNewLong )
{
return extSetWindowLong ( hwnd , nIndex , dwNewLong , pSetWindowLongA ) ;
}
LONG WINAPI extSetWindowLongW ( HWND hwnd , int nIndex , LONG dwNewLong )
{
return extSetWindowLong ( hwnd , nIndex , dwNewLong , pSetWindowLongW ) ;
}
2012-12-24 10:20:23 -05:00
BOOL WINAPI extSetWindowPos ( HWND hwnd , HWND hWndInsertAfter , int X , int Y , int cx , int cy , UINT uFlags )
{
BOOL res ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " SetWindowPos: hwnd=%x%s pos=(%d,%d) dim=(%d,%d) Flags=%x \n " ,
2013-01-04 10:30:38 -05:00
hwnd , dxw . IsFullScreen ( ) ? " (FULLSCREEN) " : " " , X , Y , cx , cy , uFlags ) ;
2012-12-24 10:20:23 -05:00
2015-05-19 12:40:46 -04:00
// when not in fullscreen mode, just proxy the call
if ( ! dxw . IsFullScreen ( ) ) {
2012-12-24 10:20:23 -05:00
res = ( * pSetWindowPos ) ( hwnd , hWndInsertAfter , X , Y , cx , cy , uFlags ) ;
if ( ! res ) OutTraceE ( " SetWindowPos: ERROR err=%d at %d \n " , GetLastError ( ) , __LINE__ ) ;
return res ;
}
2015-05-19 12:40:46 -04:00
// in fullscreen, but a child window inside .....
if ( ! dxw . IsDesktop ( hwnd ) ) {
RECT r ;
r . left = X ;
r . right = X + cx ;
r . top = Y ;
r . bottom = Y + cy ;
if ( ( * pGetWindowLongA ) ( hwnd , GWL_STYLE ) & WS_CHILD ) {
r = dxw . MapClientRect ( & r ) ;
}
else {
//r = dxw.MapWindowRect(&r);
}
X = r . left ;
Y = r . top ;
cx = r . right - r . left ;
cy = r . bottom - r . top ;
res = ( * pSetWindowPos ) ( hwnd , hWndInsertAfter , X , Y , cx , cy , uFlags ) ;
if ( ! res ) OutTraceE ( " SetWindowPos: ERROR err=%d at %d \n " , GetLastError ( ) , __LINE__ ) ;
//HFONT hFont;
//hFont=CreateFont (
// 30, 0, 0, 0, FW_DONTCARE, FALSE, FALSE,
// FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
// DEFAULT_PITCH | FF_SWISS, NULL); // "Arial");
//SendMessage (hwnd, WM_SETFONT, WPARAM (hFont), TRUE);
return res ;
}
if ( dxw . dwFlags1 & LOCKWINPOS ) {
2012-12-24 10:20:23 -05:00
// Note: any attempt to change the window position, no matter where and how, through the
// SetWindowPos API is causing resizing to the default 1:1 pixed size in Commandos.
// in such cases, there is incompatibility between LOCKWINPOS and LOCKWINSTYLE.
2013-12-22 11:38:36 -05:00
OutTraceDW ( " SetWindowPos: locked position \n " ) ;
2012-12-24 10:20:23 -05:00
return 1 ;
}
2013-01-04 10:30:38 -05:00
if ( dxw . dwFlags1 & PREVENTMAXIMIZE ) {
2012-12-24 10:20:23 -05:00
int UpdFlag = 0 ;
int MaxX , MaxY ;
2013-01-19 11:16:54 -05:00
MaxX = dxw . iSizX ;
MaxY = dxw . iSizY ;
2013-01-04 10:30:38 -05:00
if ( ! MaxX ) MaxX = dxw . GetScreenWidth ( ) ;
if ( ! MaxY ) MaxY = dxw . GetScreenHeight ( ) ;
2012-12-24 10:20:23 -05:00
if ( cx > MaxX ) { cx = MaxX ; UpdFlag = 1 ; }
if ( cy > MaxY ) { cy = MaxY ; UpdFlag = 1 ; }
if ( UpdFlag )
2013-12-22 11:38:36 -05:00
OutTraceDW ( " SetWindowPos: using max dim=(%d,%d) \n " , cx , cy ) ;
2012-12-24 10:20:23 -05:00
}
// useful??? to be demonstrated....
// when altering main window in fullscreen mode, fix the coordinates for borders
2013-12-27 11:38:38 -05:00
DWORD dwCurStyle , dwExStyle ;
HMENU hMenu ;
2012-12-24 10:20:23 -05:00
RECT rect ;
rect . top = rect . left = 0 ;
rect . right = cx ; rect . bottom = cy ;
2014-04-22 12:39:07 -04:00
dwCurStyle = ( * pGetWindowLongA ) ( hwnd , GWL_STYLE ) ;
dwExStyle = ( * pGetWindowLongA ) ( hwnd , GWL_EXSTYLE ) ;
2014-11-01 12:38:41 -04:00
// BEWARE: from MSDN - If the window is a child window, the return value is undefined.
hMenu = ( dwCurStyle & WS_CHILD ) ? NULL : GetMenu ( hwnd ) ;
2013-12-27 11:38:38 -05:00
AdjustWindowRectEx ( & rect , dwCurStyle , ( hMenu ! = NULL ) , dwExStyle ) ;
2015-07-04 12:40:35 -04:00
if ( hMenu & & ( hMenu ! = ( HMENU ) - 1 ) ) __try { CloseHandle ( hMenu ) ; } __except ( EXCEPTION_EXECUTE_HANDLER ) { } ;
2012-12-24 10:20:23 -05:00
cx = rect . right ; cy = rect . bottom ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " SetWindowPos: main form hwnd=%x fixed size=(%d,%d) \n " , hwnd , cx , cy ) ;
2012-12-24 10:20:23 -05:00
res = ( * pSetWindowPos ) ( hwnd , hWndInsertAfter , X , Y , cx , cy , uFlags ) ;
if ( ! res ) OutTraceE ( " SetWindowPos: ERROR err=%d at %d \n " , GetLastError ( ) , __LINE__ ) ;
return res ;
}
HDWP WINAPI extDeferWindowPos ( HDWP hWinPosInfo , HWND hwnd , HWND hWndInsertAfter , int X , int Y , int cx , int cy , UINT uFlags )
{
2013-08-25 12:38:13 -04:00
// v2.02.31: heavily used by "Imperialism II" !!!
2012-12-24 10:20:23 -05:00
HDWP res ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " DeferWindowPos: hwnd=%x%s pos=(%d,%d) dim=(%d,%d) Flags=%x \n " ,
2013-01-04 10:30:38 -05:00
hwnd , dxw . IsFullScreen ( ) ? " (FULLSCREEN) " : " " , X , Y , cx , cy , uFlags ) ;
2012-12-24 10:20:23 -05:00
2013-08-25 12:38:13 -04:00
if ( dxw . IsFullScreen ( ) ) {
dxw . MapClient ( & X , & Y , & cx , & cy ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " DeferWindowPos: remapped pos=(%d,%d) dim=(%d,%d) \n " , X , Y , cx , cy ) ;
2012-12-24 10:20:23 -05:00
}
2013-01-19 11:16:54 -05:00
res = ( * pGDIDeferWindowPos ) ( hWinPosInfo , hwnd , hWndInsertAfter , X , Y , cx , cy , uFlags ) ;
2012-12-24 10:20:23 -05:00
if ( ! res ) OutTraceE ( " DeferWindowPos: ERROR err=%d at %d \n " , GetLastError ( ) , __LINE__ ) ;
return res ;
}
2014-08-13 12:39:40 -04:00
LRESULT WINAPI extSendMessage ( char * apiname , SendMessage_Type pSendMessage , HWND hwnd , UINT Msg , WPARAM wParam , LPARAM lParam )
2012-12-24 10:20:23 -05:00
{
2013-07-21 12:38:09 -04:00
LRESULT ret ;
2014-08-13 12:39:40 -04:00
OutTraceW ( " %s: hwnd=%x WinMsg=[0x%x]%s(%x,%x) \n " ,
apiname , hwnd , Msg , ExplainWinMessage ( Msg ) , wParam , lParam ) ;
2013-10-08 12:38:12 -04:00
2013-07-21 12:38:09 -04:00
if ( dxw . dwFlags1 & MODIFYMOUSE ) {
switch ( Msg ) {
case WM_MOUSEMOVE :
case WM_MOUSEWHEEL :
case WM_LBUTTONDOWN :
case WM_LBUTTONUP :
case WM_LBUTTONDBLCLK :
case WM_RBUTTONDOWN :
case WM_RBUTTONUP :
case WM_RBUTTONDBLCLK :
case WM_MBUTTONDOWN :
case WM_MBUTTONUP :
case WM_MBUTTONDBLCLK :
// revert here the WindowProc mouse correction
POINT prev , curr ;
RECT rect ;
prev . x = LOWORD ( lParam ) ;
prev . y = HIWORD ( lParam ) ;
( * pGetClientRect ) ( dxw . GethWnd ( ) , & rect ) ;
curr . x = ( prev . x * rect . right ) / dxw . GetScreenWidth ( ) ;
curr . y = ( prev . y * rect . bottom ) / dxw . GetScreenHeight ( ) ;
2013-07-09 12:38:16 -04:00
if ( Msg = = WM_MOUSEWHEEL ) { // v2.02.33 mousewheel fix
POINT upleft = { 0 , 0 } ;
( * pClientToScreen ) ( dxw . GethWnd ( ) , & upleft ) ;
curr = dxw . AddCoordinates ( curr , upleft ) ;
}
2013-07-21 12:38:09 -04:00
lParam = MAKELPARAM ( curr . x , curr . y ) ;
2014-08-13 12:39:40 -04:00
OutTraceC ( " %s: hwnd=%x pos XY=(%d,%d)->(%d,%d) \n " , apiname , hwnd , prev . x , prev . y , curr . x , curr . y ) ;
2013-07-21 12:38:09 -04:00
break ;
default :
break ;
}
2012-12-24 10:20:23 -05:00
}
2014-02-02 11:38:46 -05:00
ret = ( * pSendMessage ) ( hwnd , Msg , wParam , lParam ) ;
2014-08-13 12:39:40 -04:00
OutTraceW ( " %s: lresult=%x \n " , apiname , ret ) ;
2013-07-21 12:38:09 -04:00
return ret ;
2012-12-24 10:20:23 -05:00
}
2014-02-02 11:38:46 -05:00
LRESULT WINAPI extSendMessageA ( HWND hwnd , UINT Msg , WPARAM wParam , LPARAM lParam )
{
2014-08-13 12:39:40 -04:00
return extSendMessage ( " SendMessageA " , pSendMessageA , hwnd , Msg , wParam , lParam ) ;
2014-02-02 11:38:46 -05:00
}
LRESULT WINAPI extSendMessageW ( HWND hwnd , UINT Msg , WPARAM wParam , LPARAM lParam )
{
2014-08-13 12:39:40 -04:00
return extSendMessage ( " SendMessageW " , pSendMessageW , hwnd , Msg , wParam , lParam ) ;
2014-02-02 11:38:46 -05:00
}
2013-07-21 12:38:09 -04:00
HCURSOR WINAPI extSetCursor ( HCURSOR hCursor )
2012-12-24 10:20:23 -05:00
{
2013-07-21 12:38:09 -04:00
HCURSOR ret ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
ret = ( * pSetCursor ) ( hCursor ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GDI.SetCursor: Cursor=%x, ret=%x \n " , hCursor , ret ) ;
2013-07-21 12:38:09 -04:00
//MessageBox(0, "SelectPalette", "GDI32.dll", MB_OK | MB_ICONEXCLAMATION);
return ret ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
BOOL WINAPI extGetCursorPos ( LPPOINT lppoint )
2012-12-24 10:20:23 -05:00
{
HRESULT res ;
2013-07-21 12:38:09 -04:00
static int PrevX , PrevY ;
POINT prev ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
if ( dxw . dwFlags1 & SLOWDOWN ) dxw . DoSlow ( 2 ) ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
if ( pGetCursorPos ) {
res = ( * pGetCursorPos ) ( lppoint ) ;
}
else {
lppoint - > x = 0 ; lppoint - > y = 0 ;
res = 1 ;
}
prev = * lppoint ;
* lppoint = dxw . ScreenToClient ( * lppoint ) ;
* lppoint = dxw . FixCursorPos ( * lppoint ) ;
2013-12-27 11:38:38 -05:00
2013-07-21 12:38:09 -04:00
GetHookInfo ( ) - > CursorX = ( short ) lppoint - > x ;
GetHookInfo ( ) - > CursorY = ( short ) lppoint - > y ;
OutTraceC ( " GetCursorPos: FIXED pos=(%d,%d)->(%d,%d) \n " , prev . x , prev . y , lppoint - > x , lppoint - > y ) ;
return res ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
BOOL WINAPI extSetCursorPos ( int x , int y )
2012-12-24 10:20:23 -05:00
{
2013-07-21 12:38:09 -04:00
BOOL res ;
int PrevX , PrevY ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
PrevX = x ;
PrevY = y ;
if ( dxw . dwFlags2 & KEEPCURSORFIXED ) {
OutTraceC ( " SetCursorPos: FIXED pos=(%d,%d) \n " , x , y ) ;
LastCurPosX = x ;
LastCurPosY = y ;
return 1 ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
if ( dxw . dwFlags1 & SLOWDOWN ) dxw . DoSlow ( 2 ) ;
if ( dxw . dwFlags1 & KEEPCURSORWITHIN ) {
// Intercept SetCursorPos outside screen boundaries (used as Cursor OFF in some games)
if ( ( y < 0 ) | | ( y > = ( int ) dxw . GetScreenHeight ( ) ) | | ( x < 0 ) | | ( x > = ( int ) dxw . GetScreenWidth ( ) ) ) return 1 ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
if ( dxw . dwFlags1 & MODIFYMOUSE ) {
POINT cur ;
RECT rect ;
// find window metrics
if ( ! ( * pGetClientRect ) ( dxw . GethWnd ( ) , & rect ) ) {
// report error and ignore ...
OutTraceE ( " GetClientRect(%x) ERROR %d at %d \n " , dxw . GethWnd ( ) , GetLastError ( ) , __LINE__ ) ;
return 0 ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
x = x * rect . right / dxw . GetScreenWidth ( ) ;
y = y * rect . bottom / dxw . GetScreenHeight ( ) ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
// check for boundaries (???)
if ( x > = rect . right ) x = rect . right - 1 ;
if ( x < 0 ) x = 0 ;
if ( y > = rect . bottom ) y = rect . bottom - 1 ;
if ( y < 0 ) y = 0 ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
// make it screen absolute
cur . x = x ;
cur . y = y ;
if ( ! ( * pClientToScreen ) ( dxw . GethWnd ( ) , & cur ) ) {
OutTraceE ( " ClientToScreen(%x) ERROR %d at %d \n " , dxw . GethWnd ( ) , GetLastError ( ) , __LINE__ ) ;
return 0 ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
x = cur . x ;
y = cur . y ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
res = 0 ;
if ( pSetCursorPos ) res = ( * pSetCursorPos ) ( x , y ) ;
2012-12-24 10:20:23 -05:00
2014-02-07 11:39:27 -05:00
OutTraceC ( " SetCursorPos: res=%x XY=(%d,%d)->(%d,%d) \n " , res , PrevX , PrevY , x , y ) ;
2012-12-24 10:20:23 -05:00
return res ;
}
2013-07-21 12:38:09 -04:00
BOOL WINAPI extPeekMessage ( LPMSG lpMsg , HWND hwnd , UINT wMsgFilterMin , UINT wMsgFilterMax , UINT wRemoveMsg )
2012-12-24 10:20:23 -05:00
{
2013-07-21 12:38:09 -04:00
BOOL res ;
2013-09-22 12:38:19 -04:00
2014-12-10 11:39:52 -05:00
if ( ( wMsgFilterMin = = 0 ) & & ( wMsgFilterMax = = 0 ) ) {
// no filtering, everything is good
res = ( * pPeekMessage ) ( lpMsg , hwnd , wMsgFilterMin , wMsgFilterMax , ( wRemoveMsg & 0x000F ) ) ;
}
else {
MSG Dummy ;
// better eliminate all messages before and after the selected range !!!!
//if(wMsgFilterMin)(*pPeekMessage)(&Dummy, hwnd, 0, wMsgFilterMin-1, TRUE);
if ( wMsgFilterMin > 0x0F ) ( * pPeekMessage ) ( & Dummy , hwnd , 0x0F , wMsgFilterMin - 1 , TRUE ) ;
res = ( * pPeekMessage ) ( lpMsg , hwnd , wMsgFilterMin , wMsgFilterMax , ( wRemoveMsg & 0x000F ) ) ;
if ( wMsgFilterMax < WM_KEYFIRST ) ( * pPeekMessage ) ( & Dummy , hwnd , wMsgFilterMax + 1 , WM_KEYFIRST - 1 , TRUE ) ; // don't touch above WM_KEYFIRST !!!!
}
if ( res )
OutTraceW ( " PeekMessage: ANY lpmsg=%x hwnd=%x filter=(%x-%x) remove=%x(%s) msg=%x(%s) wparam=%x, lparam=%x pt=(%d,%d) res=%x \n " ,
lpMsg , lpMsg - > hwnd , wMsgFilterMin , wMsgFilterMax , wRemoveMsg , ExplainPeekRemoveMsg ( wRemoveMsg ) ,
lpMsg - > message , ExplainWinMessage ( lpMsg - > message & 0xFFFF ) ,
lpMsg - > wParam , lpMsg - > lParam , lpMsg - > pt . x , lpMsg - > pt . y , res ) ;
else
OutTraceW ( " PeekMessage: ANY lpmsg=%x hwnd=%x filter=(%x-%x) remove=%x(%s) res=%x \n " ,
lpMsg , lpMsg - > hwnd , wMsgFilterMin , wMsgFilterMax , wRemoveMsg , ExplainPeekRemoveMsg ( wRemoveMsg ) , res ) ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
return res ;
2012-12-24 10:20:23 -05:00
}
2013-01-29 11:17:05 -05:00
BOOL WINAPI extClientToScreen ( HWND hwnd , LPPOINT lppoint )
2012-12-24 10:20:23 -05:00
{
2013-05-02 12:17:06 -04:00
// v2.02.10: fully revised to handle scaled windows
BOOL res ;
2013-05-16 12:19:15 -04:00
2013-01-29 11:17:05 -05:00
OutTraceB ( " ClientToScreen: hwnd=%x hWnd=%x FullScreen=%x point=(%d,%d) \n " ,
hwnd , dxw . GethWnd ( ) , dxw . IsFullScreen ( ) , lppoint - > x , lppoint - > y ) ;
2013-05-02 12:17:06 -04:00
if ( lppoint & & dxw . IsFullScreen ( ) ) {
2014-04-13 12:39:06 -04:00
// optimization: in fullscreen mode, coordinate conversion for the desktop window
// should always keep the same values inaltered
if ( hwnd ! = dxw . GethWnd ( ) ) {
* lppoint = dxw . AddCoordinates ( * lppoint , dxw . ClientOffset ( hwnd ) ) ;
}
2014-08-29 12:39:42 -04:00
OutTraceB ( " ClientToScreen: FIXED point=(%d,%d) \n " , lppoint - > x , lppoint - > y ) ;
2013-05-02 12:17:06 -04:00
res = TRUE ;
}
else {
res = ( * pClientToScreen ) ( hwnd , lppoint ) ;
}
return res ;
2012-12-24 10:20:23 -05:00
}
2013-01-29 11:17:05 -05:00
BOOL WINAPI extScreenToClient ( HWND hwnd , LPPOINT lppoint )
2012-12-24 10:20:23 -05:00
{
2013-05-02 12:17:06 -04:00
// v2.02.10: fully revised to handle scaled windows
BOOL res ;
2013-01-29 11:17:05 -05:00
OutTraceB ( " ScreenToClient: hwnd=%x hWnd=%x FullScreen=%x point=(%d,%d) \n " ,
hwnd , dxw . GethWnd ( ) , dxw . IsFullScreen ( ) , lppoint - > x , lppoint - > y ) ;
2013-05-16 12:19:15 -04:00
if ( lppoint & & ( lppoint - > x = = - 32000 ) & & ( lppoint - > y = = - 32000 ) ) return 1 ;
2013-05-02 12:17:06 -04:00
if ( lppoint & & dxw . IsFullScreen ( ) ) {
2014-04-13 12:39:06 -04:00
// optimization: in fullscreen mode, coordinate conversion for the desktop window
// should always keep the same values inaltered
if ( hwnd ! = dxw . GethWnd ( ) ) {
* lppoint = dxw . SubCoordinates ( * lppoint , dxw . ClientOffset ( hwnd ) ) ;
OutTraceB ( " ScreenToClient: FIXED point=(%d,%d) \n " , lppoint - > x , lppoint - > y ) ;
}
2013-05-02 12:17:06 -04:00
res = TRUE ;
}
else {
res = ( * pScreenToClient ) ( hwnd , lppoint ) ;
}
return res ;
2012-12-24 10:20:23 -05:00
}
BOOL WINAPI extGetClientRect ( HWND hwnd , LPRECT lpRect )
{
2013-04-04 12:17:08 -04:00
BOOL ret ;
2013-05-16 12:19:15 -04:00
OutTraceB ( " GetClientRect: whnd=%x FullScreen=%x \n " , hwnd , dxw . IsFullScreen ( ) ) ;
if ( ! lpRect ) return 0 ;
2012-12-24 10:20:23 -05:00
// proxed call
2013-04-04 12:17:08 -04:00
ret = ( * pGetClientRect ) ( hwnd , lpRect ) ;
2013-05-16 12:19:15 -04:00
if ( ! ret ) {
OutTraceE ( " GetClientRect: ERROR hwnd=%x err=%d at %d \n " , hwnd , GetLastError ( ) , __LINE__ ) ;
return ret ;
2012-12-24 10:20:23 -05:00
}
2013-05-16 12:19:15 -04:00
OutTraceB ( " GetClientRect: actual rect=(%d,%d)-(%d,%d) \n " , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom ) ;
if ( dxw . IsDesktop ( hwnd ) ) {
* lpRect = dxw . GetScreenRect ( ) ;
OutTraceB ( " GetClientRect: desktop rect=(%d,%d)-(%d,%d) \n " , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom ) ;
}
else
if ( dxw . IsFullScreen ( ) ) {
2014-07-13 12:39:33 -04:00
int w , h ;
if ( FIXCHILDSIZE ) {
if ( WinDBGetSize ( hwnd , & w , & h ) ) {
lpRect - > top = lpRect - > left = 0 ;
lpRect - > right = w ;
lpRect - > bottom = h ;
OutTraceB ( " GetClientRect: fixed rect=(%d,%d)-(%d,%d) \n " , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom ) ;
return TRUE ;
}
}
2013-05-16 12:19:15 -04:00
* lpRect = dxw . GetClientRect ( * lpRect ) ;
OutTraceB ( " GetClientRect: fixed rect=(%d,%d)-(%d,%d) \n " , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom ) ;
}
return ret ;
}
2012-12-24 10:20:23 -05:00
BOOL WINAPI extGetWindowRect ( HWND hwnd , LPRECT lpRect )
{
BOOL ret ;
2013-05-16 12:19:15 -04:00
OutTraceB ( " GetWindowRect: hwnd=%x hWnd=%x FullScreen=%x \n " , hwnd , dxw . GethWnd ( ) , dxw . IsFullScreen ( ) ) ;
ret = ( * pGetWindowRect ) ( hwnd , lpRect ) ;
if ( ! ret ) {
OutTraceE ( " GetWindowRect: GetWindowRect hwnd=%x error %d at %d \n " , hwnd , GetLastError ( ) , __LINE__ ) ;
return ret ;
}
OutTraceB ( " GetWindowRect: rect=(%d,%d)-(%d,%d) \n " , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom ) ;
// minimized windows behaviour
if ( ( lpRect - > left = = - 32000 ) | | ( lpRect - > top = = - 32000 ) ) return ret ;
2012-12-24 10:20:23 -05:00
2013-05-16 12:19:15 -04:00
if ( dxw . IsDesktop ( hwnd ) ) {
// to avoid keeping track of window frame
* lpRect = dxw . GetScreenRect ( ) ;
OutTraceB ( " GetWindowRect: desktop rect=(%d,%d)-(%d,%d) \n " , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom ) ;
2012-12-24 10:20:23 -05:00
}
2013-05-16 12:19:15 -04:00
else
if ( dxw . IsFullScreen ( ) ) {
* lpRect = dxw . GetWindowRect ( * lpRect ) ;
2012-12-24 10:20:23 -05:00
2013-05-16 12:19:15 -04:00
// Diablo fix: it retrieves coordinates for the explorer window, that are as big as the real desktop!!!
if ( lpRect - > left < 0 ) lpRect - > left = 0 ;
2014-07-17 12:39:35 -04:00
// if(lpRect->left > (LONG)dxw.GetScreenWidth()) lpRect->left=dxw.GetScreenWidth();
// if(lpRect->right < 0) lpRect->right=0;
2013-05-16 12:19:15 -04:00
if ( lpRect - > right > ( LONG ) dxw . GetScreenWidth ( ) ) lpRect - > right = dxw . GetScreenWidth ( ) ;
if ( lpRect - > top < 0 ) lpRect - > top = 0 ;
2014-07-17 12:39:35 -04:00
// if(lpRect->top > (LONG)dxw.GetScreenHeight()) lpRect->top=dxw.GetScreenHeight();
// if(lpRect->bottom < 0) lpRect->bottom=0;
2013-05-16 12:19:15 -04:00
if ( lpRect - > bottom > ( LONG ) dxw . GetScreenHeight ( ) ) lpRect - > bottom = dxw . GetScreenHeight ( ) ;
OutTraceB ( " GetWindowRect: fixed rect=(%d,%d)-(%d,%d) \n " , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom ) ;
2012-12-24 10:20:23 -05:00
}
return ret ;
}
int WINAPI extMapWindowPoints ( HWND hWndFrom , HWND hWndTo , LPPOINT lpPoints , UINT cPoints )
{
2013-07-21 12:38:09 -04:00
UINT pi ;
int ret ;
2013-07-25 12:38:10 -04:00
// a rarely used API, but responsible for a painful headache: needs hooking for "Commandos 2", "Alien Nations".
2015-01-03 11:40:25 -05:00
// used also in "Full Pipe" activemovie
2015-07-04 12:40:35 -04:00
// used also in "NBA Live 99" menu screen
2012-12-24 10:20:23 -05:00
2013-12-22 11:38:36 -05:00
OutTraceDW ( " MapWindowPoints: hWndFrom=%x%s hWndTo=%x%s cPoints=%d FullScreen=%x \n " ,
2013-07-25 12:38:10 -04:00
hWndFrom , dxw . IsDesktop ( hWndFrom ) ? " (DESKTOP) " : " " ,
hWndTo , dxw . IsDesktop ( hWndTo ) ? " (DESKTOP) " : " " ,
cPoints , dxw . IsFullScreen ( ) ) ;
2013-05-02 12:17:06 -04:00
if ( IsDebug ) {
OutTrace ( " Points: " ) ;
for ( pi = 0 ; pi < cPoints ; pi + + ) OutTrace ( " (%d,%d) " , lpPoints [ pi ] . x , lpPoints [ pi ] . y ) ;
OutTrace ( " \n " ) ;
}
2013-07-21 12:38:09 -04:00
if ( dxw . IsFullScreen ( ) ) {
2013-08-25 12:38:13 -04:00
if ( dxw . IsRealDesktop ( hWndTo ) ) hWndTo = dxw . GethWnd ( ) ;
if ( dxw . IsRealDesktop ( hWndFrom ) ) hWndFrom = dxw . GethWnd ( ) ;
2012-12-24 10:20:23 -05:00
}
2013-07-25 12:38:10 -04:00
ret = ( * pMapWindowPoints ) ( hWndFrom , hWndTo , lpPoints , cPoints ) ;
2015-07-04 12:40:35 -04:00
// v2.03.16: now must scale every point (fixes "NBA Live 99")
2015-04-18 12:40:38 -04:00
// v2.03.18: in some cases it should not! "New Your Race"...
2015-07-04 12:40:35 -04:00
for ( pi = 0 ; pi < cPoints ; pi + + ) {
dxw . UnmapClient ( & lpPoints [ pi ] ) ;
}
2013-03-12 12:38:32 -04:00
2015-01-03 11:40:25 -05:00
if ( IsDebug ) {
OutTrace ( " Mapped points: " ) ;
for ( pi = 0 ; pi < cPoints ; pi + + ) OutTrace ( " (%d,%d) " , lpPoints [ pi ] . x , lpPoints [ pi ] . y ) ;
OutTrace ( " \n " ) ;
}
2015-07-04 12:40:35 -04:00
// If the function succeeds, the low-order word of the return value is the number of pixels
// added to the horizontal coordinate of each source point in order to compute the horizontal
// coordinate of each destination point. (In addition to that, if precisely one of hWndFrom
// and hWndTo is mirrored, then each resulting horizontal coordinate is multiplied by -1.)
// The high-order word is the number of pixels added to the vertical coordinate of each source
// point in order to compute the vertical coordinate of each destination point.
2013-12-22 11:38:36 -05:00
OutTraceDW ( " MapWindowPoints: ret=%x (%d,%d) \n " , ret , ( ret & 0xFFFF0000 ) > > 16 , ret & 0x0000FFFF ) ;
2013-07-25 12:38:10 -04:00
return ret ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
HWND WINAPI extGetDesktopWindow ( void )
2012-12-24 10:20:23 -05:00
{
2013-07-21 12:38:09 -04:00
HWND res ;
2012-12-24 10:20:23 -05:00
2014-07-28 12:39:37 -04:00
if ( ( ! dxw . Windowize ) | | ( dxw . dwFlags5 & DIABLOTWEAK ) ) return ( * pGetDesktopWindow ) ( ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GetDesktopWindow: FullScreen=%x \n " , dxw . IsFullScreen ( ) ) ;
2013-08-25 12:38:13 -04:00
if ( dxw . IsFullScreen ( ) ) {
2014-07-28 12:39:37 -04:00
# ifdef CREATEDESKTOP
if ( CREATEDESKTOP ) {
extern HWND hDesktopWindow ;
OutTraceDW ( " GetDesktopWindow: returning desktop emulated hwnd=%x \n " , hDesktopWindow ) ;
return hDesktopWindow ;
}
# endif
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GetDesktopWindow: returning main window hwnd=%x \n " , dxw . GethWnd ( ) ) ;
2013-07-21 12:38:09 -04:00
return dxw . GethWnd ( ) ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
else {
res = ( * pGetDesktopWindow ) ( ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GetDesktopWindow: returning desktop window hwnd=%x \n " , res ) ;
2013-07-21 12:38:09 -04:00
return res ;
2012-12-24 10:20:23 -05:00
}
}
2013-07-21 12:38:09 -04:00
int WINAPI extGetSystemMetrics ( int nindex )
2012-12-24 10:20:23 -05:00
{
2013-07-21 12:38:09 -04:00
HRESULT res ;
2013-02-06 11:19:16 -05:00
2013-07-21 12:38:09 -04:00
res = ( * pGetSystemMetrics ) ( nindex ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GetSystemMetrics: index=%x(%s), res=%d \n " , nindex , ExplainsSystemMetrics ( nindex ) , res ) ;
2013-02-06 11:19:16 -05:00
2014-12-10 11:39:52 -05:00
if ( ! dxw . Windowize ) {
// v2.02.95: if not in window mode, just implement the HIDEMULTIMONITOR flag
if ( ( nindex = = SM_CMONITORS ) & &
( dxw . dwFlags2 & HIDEMULTIMONITOR ) & &
res > 1 ) {
res = 1 ;
OutTraceDW ( " GetSystemMetrics: fix SM_CMONITORS=%d \n " , res ) ;
}
return res ;
}
2013-07-21 12:38:09 -04:00
switch ( nindex ) {
case SM_CXFULLSCREEN :
case SM_CXSCREEN :
2013-08-25 12:38:13 -04:00
case SM_CXVIRTUALSCREEN : // v2.02.31
2013-07-21 12:38:09 -04:00
res = dxw . GetScreenWidth ( ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GetSystemMetrics: fix SM_CXSCREEN=%d \n " , res ) ;
2013-07-21 12:38:09 -04:00
break ;
case SM_CYFULLSCREEN :
case SM_CYSCREEN :
2013-08-25 12:38:13 -04:00
case SM_CYVIRTUALSCREEN : // v2.02.31
2013-07-21 12:38:09 -04:00
res = dxw . GetScreenHeight ( ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GetSystemMetrics: fix SM_CYSCREEN=%d \n " , res ) ;
2013-07-21 12:38:09 -04:00
break ;
case SM_CMONITORS :
if ( ( dxw . dwFlags2 & HIDEMULTIMONITOR ) & & res > 1 ) {
res = 1 ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GetSystemMetrics: fix SM_CMONITORS=%d \n " , res ) ;
2013-07-21 12:38:09 -04:00
}
break ;
2013-01-19 11:16:54 -05:00
}
2013-05-02 12:17:06 -04:00
2013-07-21 12:38:09 -04:00
return res ;
2013-05-02 12:17:06 -04:00
}
2013-07-21 12:38:09 -04:00
ATOM WINAPI extRegisterClassExA ( WNDCLASSEX * lpwcx )
2013-05-02 12:17:06 -04:00
{
2014-02-02 11:38:46 -05:00
OutTraceDW ( " RegisterClassEx: PROXED ClassName=%s style=%x(%s) WndProc=%x cbClsExtra=%d cbWndExtra=%d hInstance=%x \n " ,
lpwcx - > lpszClassName , lpwcx - > style , ExplainStyle ( lpwcx - > style ) , lpwcx - > lpfnWndProc , lpwcx - > cbClsExtra , lpwcx - > cbWndExtra , lpwcx - > hInstance ) ;
2013-07-21 12:38:09 -04:00
return ( * pRegisterClassExA ) ( lpwcx ) ;
2012-12-24 10:20:23 -05:00
}
2014-02-02 11:38:46 -05:00
ATOM WINAPI extRegisterClassA ( WNDCLASS * lpwcx )
{
// referenced by Syberia, together with RegisterClassExA
OutTraceDW ( " RegisterClass: PROXED ClassName=%s style=%x(%s) WndProc=%x cbClsExtra=%d cbWndExtra=%d hInstance=%x \n " ,
lpwcx - > lpszClassName , lpwcx - > style , ExplainStyle ( lpwcx - > style ) , lpwcx - > lpfnWndProc , lpwcx - > cbClsExtra , lpwcx - > cbWndExtra , lpwcx - > hInstance ) ;
return ( * pRegisterClassA ) ( lpwcx ) ;
}
2014-02-07 11:39:27 -05:00
static void HookChildWndProc ( HWND hwnd , DWORD dwStyle , LPCTSTR ApiName )
{
// child window inherit the father's windproc, so if it's redirected to
// a hooker (either extWindowProc or extChildWindowProc) you have to retrieve
2014-07-13 12:39:33 -04:00
// the correct value (WinDBGetProc) before saving it (WinDBPutProc).
2014-02-07 11:39:27 -05:00
long res ;
WNDPROC pWindowProc ;
pWindowProc = ( WNDPROC ) ( * pGetWindowLongA ) ( hwnd , GWL_WNDPROC ) ;
if ( ( pWindowProc = = extWindowProc ) | |
( pWindowProc = = extChildWindowProc ) | |
( pWindowProc = = extDialogWindowProc ) ) { // avoid recursions
HWND Father ;
WNDPROC pFatherProc ;
Father = GetParent ( hwnd ) ;
2014-07-13 12:39:33 -04:00
pFatherProc = WinDBGetProc ( Father ) ;
2014-02-07 11:39:27 -05:00
OutTraceDW ( " %s: WndProc=%s father=%x WndProc=%x \n " , ApiName ,
( pWindowProc = = extWindowProc ) ? " extWindowProc " : ( ( pWindowProc = = extChildWindowProc ) ? " extChildWindowProc " : " extDialogWindowProc " ) ,
Father , pFatherProc ) ;
pWindowProc = pFatherProc ;
}
2014-07-13 12:39:33 -04:00
WinDBPutProc ( hwnd , pWindowProc ) ;
2014-02-07 11:39:27 -05:00
if ( dwStyle & WS_CHILD ) {
OutTraceDW ( " %s: Hooking CHILD hwnd=%x father WindowProc %x->%x \n " , ApiName , hwnd , pWindowProc , extChildWindowProc ) ;
res = ( * pSetWindowLongA ) ( hwnd , GWL_WNDPROC , ( LONG ) extChildWindowProc ) ;
}
else { // must be dwStyle & WS_DLGFRAME
OutTraceDW ( " %s: Hooking DLGFRAME hwnd=%x father WindowProc %x->%x \n " , ApiName , hwnd , pWindowProc , extDialogWindowProc ) ;
res = ( * pSetWindowLongA ) ( hwnd , GWL_WNDPROC , ( LONG ) extDialogWindowProc ) ;
}
if ( ! res ) OutTraceE ( " %s: SetWindowLong ERROR %x \n " , ApiName , GetLastError ( ) ) ;
}
2014-07-28 12:39:37 -04:00
HWND hControlParentWnd = NULL ;
2013-08-25 12:38:13 -04:00
static HWND WINAPI extCreateWindowCommon (
LPCTSTR ApiName ,
2013-10-21 12:38:23 -04:00
BOOL WideChar ,
2013-07-21 12:38:09 -04:00
DWORD dwExStyle ,
2013-10-21 12:38:23 -04:00
void * lpClassName ,
void * lpWindowName ,
2013-07-21 12:38:09 -04:00
DWORD dwStyle ,
int x ,
int y ,
int nWidth ,
int nHeight ,
HWND hWndParent ,
HMENU hMenu ,
HINSTANCE hInstance ,
LPVOID lpParam )
2012-12-24 10:20:23 -05:00
{
2014-04-13 12:39:06 -04:00
HWND hwnd ;
2013-07-21 12:38:09 -04:00
BOOL isValidHandle = TRUE ;
2014-07-13 12:39:33 -04:00
int iOrigW , iOrigH ;
2012-12-24 10:20:23 -05:00
2014-07-13 12:39:33 -04:00
iOrigW = nWidth ;
iOrigH = nHeight ;
2014-07-28 12:39:37 -04:00
if ( ! dxw . Windowize | | ( hWndParent = = HWND_MESSAGE ) ) { // v2.02.87: don't process message windows (hWndParent == HWND_MESSAGE)
2014-02-05 11:39:10 -05:00
if ( WideChar )
hwnd = ( * pCreateWindowExW ) ( dwExStyle , ( LPCWSTR ) lpClassName , ( LPCWSTR ) lpWindowName , dwStyle , x , y , nWidth , nHeight , hWndParent , hMenu , hInstance , lpParam ) ;
else
hwnd = ( * pCreateWindowExA ) ( dwExStyle , ( LPCSTR ) lpClassName , ( LPCSTR ) lpWindowName , dwStyle , x , y , nWidth , nHeight , hWndParent , hMenu , hInstance , lpParam ) ;
2014-02-07 11:39:27 -05:00
if ( ( dxw . dwFlags1 & HOOKCHILDWIN ) & & ( dwStyle & ( WS_CHILD | WS_DLGFRAME ) ) )
HookChildWndProc ( hwnd , dwStyle , ApiName ) ;
2014-02-05 11:39:10 -05:00
OutTraceDW ( " %s: ret=%x \n " , ApiName , hwnd ) ;
2014-02-07 11:39:27 -05:00
return hwnd ;
2014-02-05 11:39:10 -05:00
}
2013-07-21 12:38:09 -04:00
// no maximized windows in any case
if ( dxw . dwFlags1 & PREVENTMAXIMIZE ) {
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: handling PREVENTMAXIMIZE mode \n " , ApiName ) ;
2013-08-30 12:38:14 -04:00
dwStyle & = ~ WS_MAXIMIZE ;
2012-12-24 10:20:23 -05:00
}
2014-07-28 12:39:37 -04:00
# ifdef CREATEDESKTOP
if ( CREATEDESKTOP ) {
extern HWND hDesktopWindow ;
if ( dxw . IsRealDesktop ( hWndParent ) ) {
OutTraceE ( " %s: new parent win %x->%x \n " , ApiName , hWndParent , hDesktopWindow ) ;
hWndParent = hDesktopWindow ;
}
}
# endif
2013-07-21 12:38:09 -04:00
// v2.1.92: fixes size & position for auxiliary big window, often used
// for intro movies etc. : needed for ......
// evidently, this was supposed to be a fullscreen window....
// v2.1.100: fixes for "The Grinch": this game creates a new main window for OpenGL
// rendering using CW_USEDEFAULT placement and 800x600 size while the previous
// main win was 640x480 only!
// v2.02.13: if it's a WS_CHILD window, don't reposition the x,y, placement for BIG win.
2013-10-08 12:38:12 -04:00
// v2.02.30: fix (Fable - lost chapters) Fable creates a bigger win with negative x,y coordinates.
2013-07-21 12:38:09 -04:00
if (
(
2014-06-04 12:39:04 -04:00
( ( x < = 0 ) & & ( y < = 0 ) )
| |
( ( x = = CW_USEDEFAULT ) & & ( y = = CW_USEDEFAULT ) )
2013-07-21 12:38:09 -04:00
)
& &
2014-06-04 12:39:04 -04:00
(
( ( nWidth > = ( int ) dxw . GetScreenWidth ( ) ) & & ( nHeight > = ( int ) dxw . GetScreenHeight ( ) ) )
| |
( ( nWidth = = CW_USEDEFAULT ) & & ( nHeight = = CW_USEDEFAULT ) ) // good for Imperialism, but is it general?
)
2013-07-21 12:38:09 -04:00
& &
! ( dwExStyle & WS_EX_CONTROLPARENT ) // Diablo fix
& &
! ( dwStyle & WS_CHILD ) // Diablo fix
2013-03-12 12:38:32 -04:00
)
2014-07-28 12:39:37 -04:00
{
2013-07-21 12:38:09 -04:00
RECT screen ;
POINT upleft = { 0 , 0 } ;
2013-10-08 12:38:12 -04:00
// v2.02.30: fix (Fable - lost chapters)
if ( nWidth = = CW_USEDEFAULT ) nWidth = dxw . GetScreenWidth ( ) ;
if ( nHeight = = CW_USEDEFAULT ) nHeight = dxw . GetScreenHeight ( ) ;
2013-07-21 12:38:09 -04:00
// update virtual screen size if it has grown
dxw . SetScreenSize ( nWidth , nHeight ) ;
// inserted some checks here, since the main window could be destroyed
// or minimized (see "Jedi Outcast") so that you may get a dangerous
// zero size. In this case, better renew the hWnd assignement and its coordinates.
do { // fake loop
isValidHandle = FALSE ;
if ( ! ( * pGetClientRect ) ( dxw . GethWnd ( ) , & screen ) ) break ;
if ( ! ( * pClientToScreen ) ( dxw . GethWnd ( ) , & upleft ) ) break ;
if ( screen . right = = 0 | | screen . bottom = = 0 ) break ;
isValidHandle = TRUE ;
} while ( FALSE ) ;
2013-10-08 12:38:12 -04:00
if ( isValidHandle ) { // use parent's coordinates
2013-07-21 12:38:09 -04:00
if ( ! ( dwStyle & WS_CHILD ) ) {
x = upleft . x ;
y = upleft . y ;
}
nWidth = screen . right ;
nHeight = screen . bottom ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: fixed BIG win pos=(%d,%d) size=(%d,%d) \n " , ApiName , x , y , nWidth , nHeight ) ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
else {
// invalid parent coordinates: use initial placement, but leave the size.
// should also fix the window style and compensate for borders here?
2013-10-08 12:38:12 -04:00
// if (!(dwStyle & WS_CHILD)){ // commented out: can't be! see if condition
2013-07-21 12:38:09 -04:00
x = dxw . iPosX ;
y = dxw . iPosY ;
2013-10-08 12:38:12 -04:00
//}
2013-07-21 12:38:09 -04:00
nWidth = dxw . iSizX ;
nHeight = dxw . iSizY ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: renewed BIG win pos=(%d,%d) size=(%d,%d) \n " , ApiName , x , y , nWidth , nHeight ) ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
dxw . SetFullScreen ( TRUE ) ;
2013-10-08 12:38:12 -04:00
if ( dxw . Coordinates = = DXW_DESKTOP_WORKAREA ) {
RECT workarea ;
2014-11-01 12:38:41 -04:00
( * pSystemParametersInfoA ) ( SPI_GETWORKAREA , NULL , & workarea , 0 ) ;
2013-10-08 12:38:12 -04:00
x = 0 ;
y = 0 ;
nWidth = workarea . right ;
nHeight = workarea . bottom ;
2013-09-16 12:38:17 -04:00
dwStyle = 0 ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: WORKAREA win pos=(%d,%d) size=(%d,%d) \n " , ApiName , x , y , nWidth , nHeight ) ;
2013-10-08 12:38:12 -04:00
}
2013-09-16 12:38:17 -04:00
else if ( dxw . Coordinates = = DXW_DESKTOP_FULL ) {
RECT workarea ;
( * pGetClientRect ) ( ( * pGetDesktopWindow ) ( ) , & workarea ) ;
x = 0 ;
y = 0 ;
nWidth = workarea . right ;
nHeight = workarea . bottom ;
dwStyle = 0 ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: FULLDESKTOP win pos=(%d,%d) size=(%d,%d) \n " , ApiName , x , y , nWidth , nHeight ) ;
2013-09-16 12:38:17 -04:00
}
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
if ( ! dxw . IsFullScreen ( ) ) { // v2.1.63: needed for "Monster Truck Madness"
2013-10-21 12:38:23 -04:00
if ( WideChar )
2014-04-13 12:39:06 -04:00
hwnd = ( * pCreateWindowExW ) ( dwExStyle , ( LPCWSTR ) lpClassName , ( LPCWSTR ) lpWindowName , dwStyle , x , y , nWidth , nHeight , hWndParent , hMenu , hInstance , lpParam ) ;
2013-10-21 12:38:23 -04:00
else
2014-04-13 12:39:06 -04:00
hwnd = ( * pCreateWindowExA ) ( dwExStyle , ( LPCSTR ) lpClassName , ( LPCSTR ) lpWindowName , dwStyle , x , y , nWidth , nHeight , hWndParent , hMenu , hInstance , lpParam ) ;
OutTraceDW ( " %s: windowed mode ret=%x \n " , ApiName , hwnd ) ;
return hwnd ;
2013-07-21 12:38:09 -04:00
}
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
// tested on Gangsters: coordinates must be window-relative!!!
// Age of Empires....
if ( dwStyle & WS_CHILD ) {
dxw . MapClient ( & x , & y , & nWidth , & nHeight ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: fixed WS_CHILD pos=(%d,%d) size=(%d,%d) \n " ,
2013-08-25 12:38:13 -04:00
ApiName , x , y , nWidth , nHeight ) ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
// needed for Diablo, that creates a new control parent window that must be
// overlapped to the directdraw surface.
else if ( dwExStyle & WS_EX_CONTROLPARENT ) {
dxw . MapWindow ( & x , & y , & nWidth , & nHeight ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " %s: fixed WS_EX_CONTROLPARENT pos=(%d,%d) size=(%d,%d) \n " ,
2013-08-25 12:38:13 -04:00
ApiName , x , y , nWidth , nHeight ) ;
2012-12-24 10:20:23 -05:00
}
2013-08-25 12:38:13 -04:00
OutTraceB ( " %s: fixed pos=(%d,%d) size=(%d,%d) Style=%x(%s) ExStyle=%x(%s) \n " ,
ApiName , x , y , nWidth , nHeight , dwStyle , ExplainStyle ( dwStyle ) , dwExStyle , ExplainExStyle ( dwExStyle ) ) ;
2012-12-24 10:20:23 -05:00
2013-10-21 12:38:23 -04:00
if ( WideChar )
2014-04-13 12:39:06 -04:00
hwnd = ( * pCreateWindowExW ) ( dwExStyle , ( LPCWSTR ) lpClassName , ( LPCWSTR ) lpWindowName , dwStyle , x , y , nWidth , nHeight , hWndParent , hMenu , hInstance , lpParam ) ;
2013-10-21 12:38:23 -04:00
else
2014-04-13 12:39:06 -04:00
hwnd = ( * pCreateWindowExA ) ( dwExStyle , ( LPCSTR ) lpClassName , ( LPCSTR ) lpWindowName , dwStyle , x , y , nWidth , nHeight , hWndParent , hMenu , hInstance , lpParam ) ;
if ( hwnd = = ( HWND ) NULL ) {
2013-08-25 12:38:13 -04:00
OutTraceE ( " %s: ERROR err=%d Style=%x(%s) ExStyle=%x \n " ,
ApiName , GetLastError ( ) , dwStyle , ExplainStyle ( dwStyle ) , dwExStyle ) ;
2014-04-13 12:39:06 -04:00
return hwnd ;
2013-07-21 12:38:09 -04:00
}
2012-12-24 10:20:23 -05:00
2014-07-28 12:39:37 -04:00
if ( dwExStyle & WS_EX_CONTROLPARENT ) hControlParentWnd = hwnd ;
2013-03-12 12:38:32 -04:00
if ( ( ! isValidHandle ) & & dxw . IsFullScreen ( ) ) {
2014-04-13 12:39:06 -04:00
dxw . SethWnd ( hwnd ) ;
2013-07-21 12:38:09 -04:00
extern void AdjustWindowPos ( HWND , DWORD , DWORD ) ;
2014-04-22 12:39:07 -04:00
( * pSetWindowLongA ) ( hwnd , GWL_STYLE , ( dxw . dwFlags2 & MODALSTYLE ) ? 0 : WS_OVERLAPPEDWINDOW ) ;
( * pSetWindowLongA ) ( hwnd , GWL_EXSTYLE , 0 ) ;
2014-04-13 12:39:06 -04:00
OutTraceDW ( " %s: hwnd=%x, set style=WS_OVERLAPPEDWINDOW extstyle=0 \n " , ApiName , hwnd ) ;
AdjustWindowPos ( hwnd , nWidth , nHeight ) ;
( * pShowWindow ) ( hwnd , SW_SHOWNORMAL ) ;
2013-07-21 12:38:09 -04:00
}
2013-06-01 12:16:52 -04:00
2014-01-19 11:38:43 -05:00
//if ((dxw.dwFlags1 & FIXWINFRAME) && !(dwStyle & WS_CHILD))
2014-04-13 12:39:06 -04:00
if ( ( dxw . dwFlags1 & FIXWINFRAME ) & & ! ( dwStyle & WS_CHILD ) & & dxw . IsDesktop ( hwnd ) )
dxw . FixWindowFrame ( hwnd ) ;
2013-08-01 12:16:53 -04:00
2014-02-07 11:39:27 -05:00
if ( ( dxw . dwFlags1 & HOOKCHILDWIN ) & & ( dwStyle & ( WS_CHILD | WS_DLGFRAME ) ) )
HookChildWndProc ( hwnd , dwStyle , ApiName ) ;
2012-12-24 10:20:23 -05:00
2014-07-13 12:39:33 -04:00
if ( ( FIXCHILDSIZE ) & & ( dwStyle & ( WS_CHILD | WS_DLGFRAME ) ) )
WinDBPutSize ( hwnd , iOrigW , iOrigH ) ;
2014-04-12 12:40:05 -04:00
// "Hoyle Casino Empire" needs to be in a maximized state to continue after the intro movie.
// Sending a SW_MAXIMIZE message intercepted by the PREVENTMAXIMIZE handling fixes the problem.
2015-03-22 12:40:33 -04:00
//if (dxw.IsFullScreen() && (dxw.dwFlags1 & PREVENTMAXIMIZE)){
if ( ( hwnd = = dxw . GethWnd ( ) ) & & dxw . IsFullScreen ( ) & & ( dxw . dwFlags1 & PREVENTMAXIMIZE ) ) {
2014-04-12 12:40:05 -04:00
OutTraceDW ( " %s: entering maximized state \n " , ApiName ) ;
( * pShowWindow ) ( hwnd , SW_MAXIMIZE ) ;
}
2014-04-13 12:39:06 -04:00
OutTraceDW ( " %s: ret=%x \n " , ApiName , hwnd ) ;
return hwnd ;
2012-12-24 10:20:23 -05:00
}
2013-08-25 12:38:13 -04:00
static LPCSTR ClassToStr ( LPCSTR Class )
{
static char AtomBuf [ 20 + 1 ] ;
if ( ( ( DWORD ) Class & 0xFFFF0000 ) = = 0 ) {
2014-05-14 12:39:12 -04:00
sprintf ( AtomBuf , " ATOM(%X) " , ( DWORD ) Class ) ;
2013-08-25 12:38:13 -04:00
return AtomBuf ;
}
return Class ;
}
2014-05-14 12:39:12 -04:00
static LPCWSTR ClassToWStr ( LPCWSTR Class )
{
static WCHAR AtomBuf [ 20 + 1 ] ;
if ( ( ( DWORD ) Class & 0xFFFF0000 ) = = 0 ) {
swprintf ( AtomBuf , L " ATOM(%X) " , ( DWORD ) Class ) ;
return AtomBuf ;
}
return Class ;
}
2013-08-25 12:38:13 -04:00
// to do: implement and use ClassToWStr() for widechar call
HWND WINAPI extCreateWindowExW (
DWORD dwExStyle ,
LPCWSTR lpClassName ,
LPCWSTR lpWindowName ,
DWORD dwStyle ,
int x ,
int y ,
int nWidth ,
int nHeight ,
HWND hWndParent ,
HMENU hMenu ,
HINSTANCE hInstance ,
LPVOID lpParam )
{
2013-12-27 11:38:38 -05:00
if ( IsTraceDW ) {
2014-11-01 12:38:41 -04:00
char xString [ 20 ] , yString [ 20 ] , wString [ 20 ] , hString [ 20 ] ;
2013-03-12 12:38:32 -04:00
if ( x = = CW_USEDEFAULT ) strcpy ( xString , " CW_USEDEFAULT " ) ;
else sprintf ( xString , " %d " , x ) ;
if ( y = = CW_USEDEFAULT ) strcpy ( yString , " CW_USEDEFAULT " ) ;
else sprintf ( yString , " %d " , y ) ;
2014-11-01 12:38:41 -04:00
if ( nWidth = = CW_USEDEFAULT ) strcpy ( wString , " CW_USEDEFAULT " ) ;
else sprintf ( wString , " %d " , nWidth ) ;
if ( nHeight = = CW_USEDEFAULT ) strcpy ( hString , " CW_USEDEFAULT " ) ;
else sprintf ( hString , " %d " , nHeight ) ;
2014-07-28 12:39:37 -04:00
OutTrace ( " CreateWindowExW: class= \" %ls \" wname= \" %ls \" pos=(%s,%s) size=(%s,%s) Style=%x(%s) ExStyle=%x(%s) hWndParent=%x%s hMenu=%x \n " ,
2014-05-14 12:39:12 -04:00
ClassToWStr ( lpClassName ) , lpWindowName , xString , yString , wString , hString ,
2014-07-28 12:39:37 -04:00
dwStyle , ExplainStyle ( dwStyle ) , dwExStyle , ExplainExStyle ( dwExStyle ) ,
hWndParent , hWndParent = = HWND_MESSAGE ? " (HWND_MESSAGE) " : " " , hMenu ) ;
2013-03-12 12:38:32 -04:00
}
2013-08-25 12:38:13 -04:00
if ( IsDebug ) OutTrace ( " CreateWindowExW: DEBUG screen=(%d,%d) \n " , dxw . GetScreenWidth ( ) , dxw . GetScreenHeight ( ) ) ;
2013-10-21 12:38:23 -04:00
return extCreateWindowCommon ( " CreateWindowExW " , TRUE , dwExStyle , ( void * ) lpClassName , ( void * ) lpWindowName , dwStyle , x , y , nWidth , nHeight , hWndParent , hMenu , hInstance , lpParam ) ;
2013-08-25 12:38:13 -04:00
}
// GHO: pro Diablo
HWND WINAPI extCreateWindowExA (
DWORD dwExStyle ,
LPCTSTR lpClassName ,
LPCTSTR lpWindowName ,
DWORD dwStyle ,
int x ,
int y ,
int nWidth ,
int nHeight ,
HWND hWndParent ,
HMENU hMenu ,
HINSTANCE hInstance ,
LPVOID lpParam )
{
2013-12-27 11:38:38 -05:00
if ( IsTraceDW ) {
2014-11-01 12:38:41 -04:00
char xString [ 20 ] , yString [ 20 ] , wString [ 20 ] , hString [ 20 ] ;
2013-03-12 12:38:32 -04:00
if ( x = = CW_USEDEFAULT ) strcpy ( xString , " CW_USEDEFAULT " ) ;
else sprintf ( xString , " %d " , x ) ;
if ( y = = CW_USEDEFAULT ) strcpy ( yString , " CW_USEDEFAULT " ) ;
else sprintf ( yString , " %d " , y ) ;
2014-11-01 12:38:41 -04:00
if ( nWidth = = CW_USEDEFAULT ) strcpy ( wString , " CW_USEDEFAULT " ) ;
else sprintf ( wString , " %d " , nWidth ) ;
if ( nHeight = = CW_USEDEFAULT ) strcpy ( hString , " CW_USEDEFAULT " ) ;
else sprintf ( hString , " %d " , nHeight ) ;
2014-07-28 12:39:37 -04:00
OutTrace ( " CreateWindowExA: class= \" %s \" wname= \" %s \" pos=(%s,%s) size=(%s,%s) Style=%x(%s) ExStyle=%x(%s) hWndParent=%x%s hMenu=%x \n " ,
2014-11-01 12:38:41 -04:00
ClassToStr ( lpClassName ) , lpWindowName , xString , yString , wString , hString ,
2014-07-28 12:39:37 -04:00
dwStyle , ExplainStyle ( dwStyle ) , dwExStyle , ExplainExStyle ( dwExStyle ) ,
hWndParent , hWndParent = = HWND_MESSAGE ? " (HWND_MESSAGE) " : " " , hMenu ) ;
2013-03-12 12:38:32 -04:00
}
2013-08-25 12:38:13 -04:00
if ( IsDebug ) OutTrace ( " CreateWindowExA: DEBUG screen=(%d,%d) \n " , dxw . GetScreenWidth ( ) , dxw . GetScreenHeight ( ) ) ;
2013-12-27 11:38:38 -05:00
return extCreateWindowCommon ( " CreateWindowExA " , FALSE , dwExStyle , ( void * ) lpClassName , ( void * ) lpWindowName , dwStyle , x , y , nWidth , nHeight , hWndParent , hMenu , hInstance , lpParam ) ;
2013-08-25 12:38:13 -04:00
}
2013-07-21 12:38:09 -04:00
LRESULT WINAPI extCallWindowProc ( WNDPROC lpPrevWndFunc , HWND hwnd , UINT Msg , WPARAM wParam , LPARAM lParam )
2012-12-24 10:20:23 -05:00
{
2013-10-08 12:38:12 -04:00
// v2.02.30: fix (Imperialism II): apply to main window only !!!
2013-07-21 12:38:09 -04:00
HRESULT res ;
2013-06-01 12:16:52 -04:00
2013-10-08 12:38:12 -04:00
res = - 1 ;
if ( hwnd = = dxw . GethWnd ( ) ) res = FixWindowProc ( " CallWindowProc " , hwnd , Msg , wParam , & lParam ) ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
if ( res = = ( HRESULT ) - 1 )
return ( * pCallWindowProc ) ( lpPrevWndFunc , hwnd , Msg , wParam , lParam ) ;
else
return res ;
2012-12-24 10:20:23 -05:00
}
2014-02-05 11:39:10 -05:00
LRESULT WINAPI extDefWindowProcA ( HWND hwnd , UINT Msg , WPARAM wParam , LPARAM lParam )
{
// v2.02.30: fix (Imperialism II): apply to main window only !!!
HRESULT res ;
2014-08-29 12:39:42 -04:00
res = ( HRESULT ) - 1 ;
if ( hwnd = = dxw . GethWnd ( ) ) res = FixWindowProc ( " DefWindowProcA " , hwnd , Msg , wParam , & lParam ) ;
2014-02-05 11:39:10 -05:00
if ( res = = ( HRESULT ) - 1 )
return ( * pDefWindowProcA ) ( hwnd , Msg , wParam , lParam ) ;
else
return res ;
}
LRESULT WINAPI extDefWindowProcW ( HWND hwnd , UINT Msg , WPARAM wParam , LPARAM lParam )
2012-12-24 10:20:23 -05:00
{
2013-10-08 12:38:12 -04:00
// v2.02.30: fix (Imperialism II): apply to main window only !!!
2013-07-21 12:38:09 -04:00
HRESULT res ;
2013-08-01 12:16:53 -04:00
2014-08-29 12:39:42 -04:00
res = ( HRESULT ) - 1 ;
if ( hwnd = = dxw . GethWnd ( ) ) res = FixWindowProc ( " DefWindowProcW " , hwnd , Msg , wParam , & lParam ) ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
if ( res = = ( HRESULT ) - 1 )
2014-02-05 11:39:10 -05:00
return ( * pDefWindowProcW ) ( hwnd , Msg , wParam , lParam ) ;
2013-07-21 12:38:09 -04:00
else
return res ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
int WINAPI extFillRect ( HDC hdc , const RECT * lprc , HBRUSH hbr )
2012-12-24 10:20:23 -05:00
{
2013-08-25 12:38:13 -04:00
int res ;
RECT rc ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " FillRect: hdc=%x hbrush=%x rect=(%d,%d)-(%d,%d) \n " , hdc , hbr , lprc - > left , lprc - > top , lprc - > right , lprc - > bottom ) ;
2013-08-25 12:38:13 -04:00
2014-04-01 12:38:40 -04:00
if ( dxw . dwFlags4 & NOFILLRECT ) {
2014-10-30 12:39:54 -04:00
OutTraceDW ( " FillRect: SUPPRESS \n " , hdc , hbr , lprc - > left , lprc - > top , lprc - > right , lprc - > bottom ) ;
2014-04-01 12:38:40 -04:00
return TRUE ;
}
2013-08-25 12:38:13 -04:00
memcpy ( & rc , lprc , sizeof ( rc ) ) ;
2014-06-04 12:39:04 -04:00
if ( dxw . IsRealDesktop ( WindowFromDC ( hdc ) ) ) {
OutTraceDW ( " FillRect: remapped hdc to virtual desktop \n " ) ;
hdc = ( * pGDIGetDC ) ( dxw . GethWnd ( ) ) ;
}
2014-04-13 12:39:06 -04:00
if ( ! dxw . IsFullScreen ( ) ) {
// when not in fullscreen mode, just proxy the call
// but check coordinates: some games may use excessive coordinates: see "Premier Manager 98"
RECT client ;
( * pGetClientRect ) ( WindowFromDC ( hdc ) , & client ) ;
if ( rc . left < 0 ) rc . left = 0 ;
if ( rc . top < 0 ) rc . top = 0 ;
if ( rc . right > client . right ) rc . right = client . right ;
if ( rc . bottom > client . bottom ) rc . bottom = client . bottom ;
return ( * pFillRect ) ( hdc , & rc , hbr ) ;
}
2014-06-04 12:39:04 -04:00
if ( OBJ_DC = = GetObjectType ( hdc ) ) {
if ( rc . left < 0 ) rc . left = 0 ;
if ( rc . top < 0 ) rc . top = 0 ;
if ( ( DWORD ) rc . right > dxw . GetScreenWidth ( ) ) rc . right = dxw . GetScreenWidth ( ) ;
if ( ( DWORD ) rc . bottom > dxw . GetScreenHeight ( ) ) rc . bottom = dxw . GetScreenHeight ( ) ;
dxw . MapClient ( & rc ) ;
2014-04-13 12:39:06 -04:00
//dxw.MapWindow(&rc);
2013-12-22 11:38:36 -05:00
OutTraceDW ( " FillRect: fixed rect=(%d,%d)-(%d,%d) \n " , rc . left , rc . top , rc . right , rc . bottom ) ;
}
2013-08-25 12:38:13 -04:00
res = ( * pFillRect ) ( hdc , & rc , hbr ) ;
return res ;
}
int WINAPI extFrameRect ( HDC hdc , const RECT * lprc , HBRUSH hbr )
{
int res ;
RECT rc ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " FrameRect: hdc=%x hbrush=%x rect=(%d,%d)-(%d,%d) \n " , hdc , hbr , lprc - > left , lprc - > top , lprc - > right , lprc - > bottom ) ;
2013-08-25 12:38:13 -04:00
// when not in fullscreen mode, just proxy the call
if ( ! dxw . IsFullScreen ( ) ) return ( * pFrameRect ) ( hdc , lprc , hbr ) ;
2013-07-21 12:38:09 -04:00
memcpy ( & rc , lprc , sizeof ( rc ) ) ;
2013-08-25 12:38:13 -04:00
if ( OBJ_DC = = GetObjectType ( hdc ) ) {
if ( rc . left < 0 ) rc . left = 0 ;
if ( rc . top < 0 ) rc . top = 0 ;
if ( ( DWORD ) rc . right > dxw . GetScreenWidth ( ) ) rc . right = dxw . GetScreenWidth ( ) ;
if ( ( DWORD ) rc . bottom > dxw . GetScreenHeight ( ) ) rc . bottom = dxw . GetScreenHeight ( ) ;
dxw . MapClient ( & rc ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " FrameRect: fixed rect=(%d,%d)-(%d,%d) \n " , rc . left , rc . top , rc . right , rc . bottom ) ;
2013-08-25 12:38:13 -04:00
}
res = ( * pFrameRect ) ( hdc , & rc , hbr ) ;
return res ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
BOOL WINAPI extClipCursor ( RECT * lpRectArg )
2012-12-24 10:20:23 -05:00
{
2013-07-21 12:38:09 -04:00
// reference: hooking and setting ClipCursor is mandatori in "Emergency: Fighters for Life"
// where the application expects the cursor to be moved just in a inner rect within the
// main window surface.
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
BOOL res ;
RECT * lpRect ;
RECT Rect ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
if ( IsTraceC ) {
if ( lpRectArg )
OutTrace ( " ClipCursor: rect=(%d,%d)-(%d,%d) \n " ,
lpRectArg - > left , lpRectArg - > top , lpRectArg - > right , lpRectArg - > bottom ) ;
else
OutTrace ( " ClipCursor: rect=(NULL) \n " ) ;
}
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
if ( ! ( dxw . dwFlags1 & ENABLECLIPPING ) ) return 1 ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
if ( lpRectArg ) {
Rect = * lpRectArg ;
lpRect = & Rect ;
2012-12-24 10:20:23 -05:00
}
else
2013-07-21 12:38:09 -04:00
lpRect = NULL ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
if ( dxw . dwFlags1 & MODIFYMOUSE ) {
// save desired clip region
2013-11-10 11:38:24 -05:00
// v2.02.39: fix - do not attempt to write to NULL lpRect
2013-07-21 12:38:09 -04:00
if ( lpRect ) {
ClipRegion = * lpRectArg ;
lpClipRegion = & ClipRegion ;
2013-11-10 11:38:24 -05:00
* lpRect = dxw . MapWindowRect ( lpRect ) ;
2013-07-21 12:38:09 -04:00
}
else
lpClipRegion = NULL ;
}
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
if ( pClipCursor ) res = ( * pClipCursor ) ( lpRect ) ;
2013-12-22 11:38:36 -05:00
if ( lpRect ) OutTraceDW ( " ClipCursor: REMAPPED rect=(%d,%d)-(%d,%d) res=%x \n " , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom , res ) ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
return TRUE ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
BOOL WINAPI extGetClipCursor ( LPRECT lpRect )
2012-12-24 10:20:23 -05:00
{
2013-07-21 12:38:09 -04:00
// v2.1.93: if ENABLECLIPPING, return the saved clip rect coordinates
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
BOOL ret ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
// proxy....
if ( ! ( dxw . dwFlags1 & ENABLECLIPPING ) ) {
ret = ( * pGetClipCursor ) ( lpRect ) ;
2015-02-15 11:40:23 -05:00
// v2.03.11: fix for "SubCulture" mouse movement
if ( lpRect & & dxw . Windowize ) * lpRect = dxw . GetScreenRect ( ) ;
2013-12-22 11:38:36 -05:00
if ( IsTraceDDRAW ) {
2013-07-21 12:38:09 -04:00
if ( lpRect )
2015-02-15 11:40:23 -05:00
OutTrace ( " GetClipCursor: rect=(%d,%d)-(%d,%d) ret=%d \n " ,
2013-07-21 12:38:09 -04:00
lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom , ret ) ;
else
2015-02-15 11:40:23 -05:00
OutTrace ( " GetClipCursor: rect=(NULL) ret=%d \n " , ret ) ;
2013-07-21 12:38:09 -04:00
}
return ret ;
}
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
if ( lpRect ) {
if ( lpClipRegion )
* lpRect = ClipRegion ;
2015-02-15 11:40:23 -05:00
else
* lpRect = dxw . GetScreenRect ( ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GetClipCursor: rect=(%d,%d)-(%d,%d) ret=%d \n " ,
2013-07-21 12:38:09 -04:00
lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom , TRUE ) ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
return TRUE ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
LONG WINAPI extEnumDisplaySettings ( LPCTSTR lpszDeviceName , DWORD iModeNum , DEVMODE * lpDevMode )
2012-12-24 10:20:23 -05:00
{
2014-04-01 12:38:40 -04:00
LONG res ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " EnumDisplaySettings: Devicename=%s ModeNum=%x \n " , lpszDeviceName , iModeNum ) ;
2015-07-01 12:40:14 -04:00
res = ( * pEnumDisplaySettings ) ( lpszDeviceName , iModeNum , lpDevMode ) ;
if ( dxw . dwFlags4 & LIMITSCREENRES ) {
# define HUGE 100000
DWORD maxw , maxh ;
maxw = maxh = HUGE ;
switch ( dxw . MaxScreenRes ) {
case DXW_NO_LIMIT : maxw = HUGE ; maxh = HUGE ; break ;
case DXW_LIMIT_320x200 : maxw = 320 ; maxh = 200 ; break ;
case DXW_LIMIT_640x480 : maxw = 640 ; maxh = 480 ; break ;
case DXW_LIMIT_800x600 : maxw = 800 ; maxh = 600 ; break ;
case DXW_LIMIT_1024x768 : maxw = 1024 ; maxh = 768 ; break ;
case DXW_LIMIT_1280x960 : maxw = 1280 ; maxh = 960 ; break ;
}
if ( ( lpDevMode - > dmPelsWidth > maxw ) | | ( lpDevMode - > dmPelsHeight > maxh ) ) {
OutTraceDW ( " EnumDisplaySettings: limit device size=(%d,%d) \n " , maxw , maxh ) ;
lpDevMode - > dmPelsWidth = maxw ;
lpDevMode - > dmPelsHeight = maxh ;
2014-04-01 12:38:40 -04:00
}
}
2015-07-01 12:40:14 -04:00
return res ;
2012-12-24 10:20:23 -05:00
}
2013-12-22 11:38:36 -05:00
LONG WINAPI extChangeDisplaySettingsA ( DEVMODEA * lpDevMode , DWORD dwflags )
2012-12-24 10:20:23 -05:00
{
2013-12-22 11:38:36 -05:00
if ( IsTraceDDRAW ) {
2015-11-02 11:40:21 -05:00
char sInfo [ 1024 ] ;
strcpy ( sInfo , " " ) ;
if ( lpDevMode ) sprintf ( sInfo , " DeviceName=%s fields=%x(%s) size=(%d x %d) bpp=%d " ,
2013-12-22 11:38:36 -05:00
lpDevMode - > dmDeviceName , lpDevMode - > dmFields , ExplainDevModeFields ( lpDevMode - > dmFields ) ,
2013-07-21 12:38:09 -04:00
lpDevMode - > dmPelsWidth , lpDevMode - > dmPelsHeight , lpDevMode - > dmBitsPerPel ) ;
2015-11-02 11:40:21 -05:00
OutTrace ( " ChangeDisplaySettingsA: lpDevMode=%x flags=%x(%s)%s \n " ,
lpDevMode , dwflags , ExplainChangeDisplaySettingsFlags ( dwflags ) , sInfo ) ;
2013-07-21 12:38:09 -04:00
}
2012-12-24 10:20:23 -05:00
2014-02-05 11:39:10 -05:00
if ( dxw . Windowize )
return MyChangeDisplaySettings ( " ChangeDisplaySettingsA " , FALSE , lpDevMode , dwflags ) ;
else
2014-05-14 12:39:12 -04:00
return ( * pChangeDisplaySettingsExA ) ( NULL , lpDevMode , NULL , dwflags , NULL ) ;
2012-12-24 10:20:23 -05:00
}
2013-12-22 11:38:36 -05:00
LONG WINAPI extChangeDisplaySettingsW ( DEVMODEW * lpDevMode , DWORD dwflags )
2012-12-24 10:20:23 -05:00
{
2013-12-22 11:38:36 -05:00
if ( IsTraceDDRAW ) {
2015-11-02 11:40:21 -05:00
char sInfo [ 1024 ] ;
strcpy ( sInfo , " " ) ;
if ( lpDevMode ) sprintf ( sInfo , " DeviceName=%ls fields=%x(%s) size=(%d x %d) bpp=%d " ,
2013-12-22 11:38:36 -05:00
lpDevMode - > dmDeviceName , lpDevMode - > dmFields , ExplainDevModeFields ( lpDevMode - > dmFields ) ,
lpDevMode - > dmPelsWidth , lpDevMode - > dmPelsHeight , lpDevMode - > dmBitsPerPel ) ;
2015-11-02 11:40:21 -05:00
OutTrace ( " ChangeDisplaySettingsW: lpDevMode=%x flags=%x(%s)%s \n " ,
lpDevMode , dwflags , ExplainChangeDisplaySettingsFlags ( dwflags ) , sInfo ) ;
2013-12-22 11:38:36 -05:00
}
2014-02-05 11:39:10 -05:00
if ( dxw . Windowize )
return MyChangeDisplaySettings ( " ChangeDisplaySettingsW " , TRUE , lpDevMode , dwflags ) ;
else
return ( * pChangeDisplaySettingsW ) ( lpDevMode , dwflags ) ;
2013-12-22 11:38:36 -05:00
}
LONG WINAPI extChangeDisplaySettingsExA ( LPCTSTR lpszDeviceName , DEVMODEA * lpDevMode , HWND hwnd , DWORD dwflags , LPVOID lParam )
{
if ( IsTraceDDRAW ) {
2015-11-02 11:40:21 -05:00
char sInfo [ 1024 ] ;
strcpy ( sInfo , " " ) ;
if ( lpDevMode ) sprintf ( sInfo , " DeviceName=%s fields=%x(%s) size=(%d x %d) bpp=%d " ,
2013-12-22 11:38:36 -05:00
lpDevMode - > dmDeviceName , lpDevMode - > dmFields , ExplainDevModeFields ( lpDevMode - > dmFields ) ,
lpDevMode - > dmPelsWidth , lpDevMode - > dmPelsHeight , lpDevMode - > dmBitsPerPel ) ;
2015-11-02 11:40:21 -05:00
OutTrace ( " ChangeDisplaySettingsExA: DeviceName=%s lpDevMode=%x flags=%x(%s)%s \n " ,
lpszDeviceName , lpDevMode , dwflags , ExplainChangeDisplaySettingsFlags ( dwflags ) , sInfo ) ;
2013-12-22 11:38:36 -05:00
}
2014-02-05 11:39:10 -05:00
if ( dxw . Windowize )
return MyChangeDisplaySettings ( " ChangeDisplaySettingsExA " , FALSE , lpDevMode , dwflags ) ;
else
return ( * pChangeDisplaySettingsExA ) ( lpszDeviceName , lpDevMode , hwnd , dwflags , lParam ) ;
2013-12-22 11:38:36 -05:00
}
LONG WINAPI extChangeDisplaySettingsExW ( LPCTSTR lpszDeviceName , DEVMODEW * lpDevMode , HWND hwnd , DWORD dwflags , LPVOID lParam )
{
if ( IsTraceDDRAW ) {
2015-11-02 11:40:21 -05:00
char sInfo [ 1024 ] ;
strcpy ( sInfo , " " ) ;
if ( lpDevMode ) sprintf ( sInfo , " DeviceName=%ls fields=%x(%s) size=(%d x %d) bpp=%d " ,
2013-12-22 11:38:36 -05:00
lpDevMode - > dmDeviceName , lpDevMode - > dmFields , ExplainDevModeFields ( lpDevMode - > dmFields ) ,
2013-07-21 12:38:09 -04:00
lpDevMode - > dmPelsWidth , lpDevMode - > dmPelsHeight , lpDevMode - > dmBitsPerPel ) ;
2015-11-02 11:40:21 -05:00
OutTrace ( " ChangeDisplaySettingsExW: DeviceName=%ls lpDevMode=%x flags=%x(%s)%s \n " ,
lpszDeviceName , lpDevMode , dwflags , ExplainChangeDisplaySettingsFlags ( dwflags ) , sInfo ) ;
2012-12-24 10:20:23 -05:00
}
2013-07-21 12:38:09 -04:00
2014-02-05 11:39:10 -05:00
if ( dxw . Windowize )
return MyChangeDisplaySettings ( " ChangeDisplaySettingsExW " , TRUE , lpDevMode , dwflags ) ;
else
return ( * pChangeDisplaySettingsExW ) ( lpszDeviceName , lpDevMode , hwnd , dwflags , lParam ) ;
2012-12-24 10:20:23 -05:00
}
2015-04-26 12:40:41 -04:00
static HDC WINAPI sGetDC ( HWND hwnd , char * ApiName )
2012-12-24 10:20:23 -05:00
{
2015-04-26 12:40:41 -04:00
// to do: add parameter and reference to pGDIGetDCEx to merge properly GetDC and GetDCEx
2013-07-21 12:38:09 -04:00
HDC ret ;
HWND lochwnd ;
2012-12-24 10:20:23 -05:00
2013-07-21 12:38:09 -04:00
lochwnd = hwnd ;
2015-04-26 12:40:41 -04:00
2013-08-25 12:38:13 -04:00
if ( dxw . IsRealDesktop ( hwnd ) ) {
2015-04-26 12:40:41 -04:00
OutTraceDW ( " %s: desktop remapping hwnd=%x->%x \n " , ApiName , hwnd , dxw . GethWnd ( ) ) ;
2013-07-21 12:38:09 -04:00
lochwnd = dxw . GethWnd ( ) ;
2012-12-24 10:20:23 -05:00
}
2015-04-26 12:40:41 -04:00
# ifdef HANDLEFLIPTOGDI
extern BOOL bFlippedDC ;
if ( bFlippedDC ) {
extern HDC hFlippedDC ;
LPDIRECTDRAWSURFACE lpDDSPrim ;
lpDDSPrim = dxw . GetPrimarySurface ( ) ;
2015-10-05 12:40:44 -04:00
#if 0
// v2.03.20: beware, from this release the output from dxw.GetPrimarySurface() could be a
// zero reference counter released surface that could be used to feed a QueryInterface method,
// but would crash if used otherwise.
__try { ( * pGetDC ) ( lpDDSPrim , & hFlippedDC ) ; } __except ( EXCEPTION_EXECUTE_HANDLER ) { hFlippedDC = NULL ; } ;
# else
if ( lpDDSPrim ) ( * pGetDC ) ( lpDDSPrim , & hFlippedDC ) ;
# endif
2015-04-26 12:40:41 -04:00
OutTraceDW ( " %s: remapping flipped GDI hdc=%x \n " , ApiName , hFlippedDC ) ;
2015-10-05 12:40:44 -04:00
if ( hFlippedDC ) return hFlippedDC ;
2014-04-22 12:39:07 -04:00
}
2015-04-26 12:40:41 -04:00
# endif
2014-02-05 11:39:10 -05:00
2015-04-26 12:40:41 -04:00
switch ( GDIEmulationMode ) {
case GDIMODE_STRETCHED :
ret = ( * pGDIGetDC ) ( lochwnd ) ;
break ;
case GDIMODE_EMULATED :
ret = dxw . AcquireEmulatedDC ( lochwnd ) ;
dxw . VirtualHDC = ret ;
break ;
case GDIMODE_DIRECTDRAW :
break ;
2014-04-01 12:38:40 -04:00
}
2014-04-22 12:39:07 -04:00
2013-07-21 12:38:09 -04:00
if ( ret ) {
2015-04-26 12:40:41 -04:00
OutTraceDW ( " %s: hwnd=%x ret=%x \n " , ApiName , lochwnd , ret ) ;
2013-07-21 12:38:09 -04:00
}
else {
int err ;
err = GetLastError ( ) ;
2015-04-26 12:40:41 -04:00
OutTraceE ( " %s ERROR: hwnd=%x err=%d at %d \n " , ApiName , lochwnd , err , __LINE__ ) ;
2013-07-21 12:38:09 -04:00
if ( ( err = = ERROR_INVALID_WINDOW_HANDLE ) & & ( lochwnd ! = hwnd ) ) {
ret = ( * pGDIGetDC ) ( hwnd ) ;
if ( ret )
2015-04-26 12:40:41 -04:00
OutTraceDW ( " %s: hwnd=%x ret=%x \n " , ApiName , hwnd , ret ) ;
2013-07-21 12:38:09 -04:00
else
2015-04-26 12:40:41 -04:00
OutTraceE ( " %s ERROR: hwnd=%x err=%d at %d \n " , ApiName , hwnd , GetLastError ( ) , __LINE__ ) ;
2013-07-21 12:38:09 -04:00
}
}
2012-12-24 10:20:23 -05:00
return ret ;
}
2015-04-26 12:40:41 -04:00
HDC WINAPI extGDIGetDC ( HWND hwnd )
2013-08-30 12:38:14 -04:00
{
2015-04-26 12:40:41 -04:00
OutTraceDW ( " GDI.GetDC: hwnd=%x \n " , hwnd ) ;
return sGetDC ( hwnd , " GDI.GetDC " ) ;
2014-04-22 12:39:07 -04:00
}
2015-04-26 12:40:41 -04:00
HDC WINAPI extGDIGetDCEx ( HWND hwnd , HRGN hrgnClip , DWORD flags )
2014-04-22 12:39:07 -04:00
{
// used by Star Wars Shadow of the Empire
OutTraceDW ( " GDI.GetDCEx: hwnd=%x hrgnClip=%x flags=%x(%s) \n " , hwnd , hrgnClip , flags , ExplainGetDCExFlags ( flags ) ) ;
2015-04-26 12:40:41 -04:00
return sGetDC ( hwnd , " GDI.GetDCEx " ) ;
2013-08-30 12:38:14 -04:00
}
2013-07-21 12:38:09 -04:00
HDC WINAPI extGDIGetWindowDC ( HWND hwnd )
2012-12-24 10:20:23 -05:00
{
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GDI.GetWindowDC: hwnd=%x \n " , hwnd ) ;
2014-04-22 12:39:07 -04:00
2015-04-26 12:40:41 -04:00
// if not fullscreen or not desktop win, just proxy the call
if ( ! dxw . IsFullScreen ( ) | | ! dxw . IsDesktop ( hwnd ) ) {
HDC ret ;
ret = ( * pGDIGetWindowDC ) ( hwnd ) ;
OutTraceDW ( " GDI.GetWindowDC: hwnd=%x hdc=%x \n " , hwnd , ret ) ;
return ret ;
2014-04-22 12:39:07 -04:00
}
2015-04-26 12:40:41 -04:00
return sGetDC ( hwnd , " GDI.GetWindowDC " ) ;
2013-07-21 12:38:09 -04:00
}
int WINAPI extGDIReleaseDC ( HWND hwnd , HDC hDC )
{
int res ;
2012-12-24 10:20:23 -05:00
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GDI.ReleaseDC: hwnd=%x hdc=%x \n " , hwnd , hDC ) ;
2014-04-22 12:39:07 -04:00
2013-08-25 12:38:13 -04:00
if ( dxw . IsRealDesktop ( hwnd ) ) hwnd = dxw . GethWnd ( ) ;
2013-07-21 12:38:09 -04:00
2015-04-26 12:40:41 -04:00
# ifdef HANDLEFLIPTOGDI
extern BOOL bFlippedDC ;
extern HDC hFlippedDC ;
if ( bFlippedDC & & ( hDC = = hFlippedDC ) ) {
HRESULT ret ;
OutTraceDW ( " GDI.ReleaseDC: releasing flipped GDI hdc=%x \n " , hDC ) ;
ret = ( * pReleaseDC ) ( dxw . GetPrimarySurface ( ) , hDC ) ;
if ( ret ) OutTraceE ( " GDI.ReleaseDC ERROR: err=%x(%s) at %d \n " , ret , ExplainDDError ( ret ) , __LINE__ ) ;
2015-10-05 12:40:44 -04:00
else dxw . ScreenRefresh ( ) ;
2015-04-26 12:40:41 -04:00
return ( ret = = DD_OK ) ;
}
# endif
2014-04-22 12:39:07 -04:00
2015-04-26 12:40:41 -04:00
switch ( GDIEmulationMode ) {
case GDIMODE_STRETCHED :
res = ( * pGDIReleaseDC ) ( hwnd , hDC ) ;
break ;
case GDIMODE_EMULATED :
HDC windc ;
windc = ( * pGDIGetDC ) ( hwnd ) ;
res = dxw . ReleaseEmulatedDC ( hwnd ) ;
res = ( * pGDIReleaseDC ) ( hwnd , windc ) ;
break ;
case GDIMODE_DIRECTDRAW :
break ;
}
2014-04-22 12:39:07 -04:00
2013-07-21 12:38:09 -04:00
if ( ! res ) OutTraceE ( " GDI.ReleaseDC ERROR: err=%d at %d \n " , GetLastError ( ) , __LINE__ ) ;
return ( res ) ;
2012-12-24 10:20:23 -05:00
}
HDC WINAPI extBeginPaint ( HWND hwnd , LPPAINTSTRUCT lpPaint )
{
HDC hdc ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GDI.BeginPaint: hwnd=%x lpPaint=%x FullScreen=%x \n " , hwnd , lpPaint , dxw . IsFullScreen ( ) ) ;
2012-12-24 10:20:23 -05:00
2014-04-22 12:39:07 -04:00
// avoid access to real desktop
if ( dxw . IsRealDesktop ( hwnd ) ) hwnd = dxw . GethWnd ( ) ;
2015-04-26 12:40:41 -04:00
hdc = ( * pBeginPaint ) ( hwnd , lpPaint ) ;
2012-12-24 10:20:23 -05:00
// if not in fullscreen mode, that's all!
2013-01-04 10:30:38 -05:00
if ( ! dxw . IsFullScreen ( ) ) return hdc ;
2012-12-24 10:20:23 -05:00
2014-11-01 12:38:41 -04:00
// on CLIENTREMAPPING, resize the paint area to virtual screen size
2014-01-19 11:38:43 -05:00
if ( dxw . dwFlags1 & CLIENTREMAPPING ) lpPaint - > rcPaint = dxw . GetScreenRect ( ) ;
2014-11-01 12:38:41 -04:00
2015-04-26 12:40:41 -04:00
switch ( GDIEmulationMode ) {
case GDIMODE_STRETCHED :
break ;
case GDIMODE_EMULATED :
HDC EmuHDC ;
EmuHDC = dxw . AcquireEmulatedDC ( hwnd ) ;
lpPaint - > hdc = EmuHDC ;
hdc = EmuHDC ;
break ;
case GDIMODE_DIRECTDRAW :
( * pGDIReleaseDC ) ( hwnd , lpPaint - > hdc ) ;
2015-05-19 12:40:46 -04:00
( * pGetDC ) ( dxw . lpDDSPrimary , & PrimHDC ) ;
2015-04-26 12:40:41 -04:00
lpPaint - > hdc = PrimHDC ;
// resize the paint area to virtual screen size (see CivIII clipped panels...)
lpPaint - > rcPaint = dxw . GetScreenRect ( ) ;
OutTraceDW ( " GDI.BeginPaint(MAPGDITOPRIMARY): hdc=%x -> %x \n " , hdc , PrimHDC ) ;
hdc = PrimHDC ;
break ;
}
2014-07-17 12:39:35 -04:00
OutTraceDW ( " GDI.BeginPaint: hdc=%x rcPaint=(%d,%d)-(%d,%d) \n " ,
hdc , lpPaint - > rcPaint . left , lpPaint - > rcPaint . top , lpPaint - > rcPaint . right , lpPaint - > rcPaint . bottom ) ;
2014-11-01 12:38:41 -04:00
return hdc ;
}
2014-01-19 11:38:43 -05:00
HDC WINAPI extDDBeginPaint ( HWND hwnd , LPPAINTSTRUCT lpPaint )
{
HDC hdc ;
extern HRESULT WINAPI extGetDC ( LPDIRECTDRAWSURFACE , HDC FAR * ) ;
OutTraceDW ( " GDI.BeginPaint: hwnd=%x%s lpPaint=%x FullScreen=%x \n " ,
hwnd , dxw . IsDesktop ( hwnd ) ? " (DESKTOP) " : " " , lpPaint , dxw . IsFullScreen ( ) ) ;
if ( dxw . IsDesktop ( hwnd ) ) hwnd = dxw . GethWnd ( ) ;
hdc = ( * pBeginPaint ) ( hwnd , lpPaint ) ;
// if not in fullscreen mode, that's all!
if ( ! dxw . IsFullScreen ( ) ) return hdc ;
// on MAPGDITOPRIMARY, return the PrimHDC handle instead of the window DC
// if a primary surface has not been created yet, do it
2015-05-19 12:40:46 -04:00
if ( ! pGetDC | | ! dxw . lpDDSPrimary ) {
2014-01-19 11:38:43 -05:00
extern HRESULT WINAPI extDirectDrawCreate ( GUID FAR * , LPDIRECTDRAW FAR * , IUnknown FAR * ) ;
HRESULT res ;
LPDIRECTDRAW lpDD ;
LPDIRECTDRAWSURFACE lpDDS ;
DDSURFACEDESC ddsd ;
res = extDirectDrawCreate ( 0 , & lpDD , NULL ) ;
2014-02-05 11:39:10 -05:00
//res=extDirectDrawCreate((GUID *)&IID_IDirectDraw, &lpDD, NULL);
lpDD - > SetCooperativeLevel ( dxw . GethWnd ( ) , DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE ) ;
//lpDD->SetCooperativeLevel(dxw.GethWnd(), DDSCL_NORMAL);
2014-01-19 11:38:43 -05:00
memset ( ( void * ) & ddsd , 0 , sizeof ( DDSURFACEDESC ) ) ;
ddsd . dwSize = sizeof ( DDSURFACEDESC ) ;
ddsd . dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH ;
ddsd . ddsCaps . dwCaps = DDSCAPS_PRIMARYSURFACE ;
ddsd . dwHeight = dxw . GetScreenHeight ( ) ;
ddsd . dwWidth = dxw . GetScreenWidth ( ) ;
res = lpDD - > CreateSurface ( & ddsd , & lpDDS , NULL ) ;
2015-05-19 12:40:46 -04:00
dxw . lpDDSPrimary = lpDDS ;
2014-01-19 11:38:43 -05:00
OutTraceDW ( " GDI.BeginPaint(MAPGDITOPRIMARY): dd=%x ddsPrim=%x \n " , lpDD , lpDDS ) ;
}
2015-05-19 12:40:46 -04:00
extGetDC ( dxw . lpDDSPrimary , & PrimHDC ) ;
2014-04-22 12:39:07 -04:00
lpPaint - > hdc = PrimHDC ;
// resize the paint area to virtual screen size (see CivIII clipped panels...)
2014-01-19 11:38:43 -05:00
lpPaint - > rcPaint = dxw . GetScreenRect ( ) ;
2014-04-22 12:39:07 -04:00
OutTraceDW ( " GDI.BeginPaint(MAPGDITOPRIMARY): hdc=%x -> %x \n " , hdc , PrimHDC ) ;
return PrimHDC ;
2014-01-19 11:38:43 -05:00
}
2012-12-24 10:20:23 -05:00
BOOL WINAPI extEndPaint ( HWND hwnd , const PAINTSTRUCT * lpPaint )
{
BOOL ret ;
2015-04-26 12:40:41 -04:00
OutTraceDW ( " GDI.EndPaint: hwnd=%x lpPaint=%x lpPaint.hdc=%x lpPaint.rcpaint=(%d,%d)-(%d-%d) \n " ,
hwnd , lpPaint , lpPaint - > hdc , lpPaint - > rcPaint . left , lpPaint - > rcPaint . top , lpPaint - > rcPaint . right , lpPaint - > rcPaint . bottom ) ;
2014-01-19 11:38:43 -05:00
2015-04-26 12:40:41 -04:00
// if not fullscreen or not desktop win, just proxy the call
if ( ! dxw . IsFullScreen ( ) | | ! dxw . Windowize ) {
ret = ( * pEndPaint ) ( hwnd , lpPaint ) ;
return ret ;
}
2014-01-19 11:38:43 -05:00
2015-04-26 12:40:41 -04:00
// avoid access to real desktop
if ( dxw . IsRealDesktop ( hwnd ) ) hwnd = dxw . GethWnd ( ) ;
2014-01-19 11:38:43 -05:00
2015-04-26 12:40:41 -04:00
switch ( GDIEmulationMode ) {
case GDIMODE_STRETCHED :
ret = ( * pEndPaint ) ( hwnd , lpPaint ) ;
break ;
case GDIMODE_EMULATED :
ret = dxw . ReleaseEmulatedDC ( hwnd ) ;
break ;
case GDIMODE_DIRECTDRAW :
break ;
2014-04-12 12:40:05 -04:00
}
2015-04-26 12:40:41 -04:00
if ( ret )
OutTraceDW ( " GDI.EndPaint: hwnd=%x ret=%x \n " , hwnd , ret ) ;
else
OutTraceE ( " GDI.EndPaint ERROR: err=%d at %d \n " , GetLastError ( ) , __LINE__ ) ;
2012-12-24 10:20:23 -05:00
return ret ;
}
2014-04-22 12:39:07 -04:00
2014-11-01 12:38:41 -04:00
BOOL WINAPI extDDEndPaint ( HWND hwnd , const PAINTSTRUCT * lpPaint )
{
BOOL ret ;
extern HRESULT WINAPI extReleaseDC ( LPDIRECTDRAWSURFACE lpdds , HDC FAR hdc ) ;
extern HRESULT WINAPI extGetDC ( LPDIRECTDRAWSURFACE , HDC FAR * ) ;
extern HRESULT WINAPI extBlt ( LPDIRECTDRAWSURFACE lpdds , LPRECT lpdestrect , LPDIRECTDRAWSURFACE lpddssrc , LPRECT lpsrcrect , DWORD dwflags , LPDDBLTFX lpddbltfx ) ;
2014-04-22 12:39:07 -04:00
OutTraceDW ( " GDI.EndPaint(DD): hwnd=%x%s lpPaint=%x lpPaint.hdc=%x \n " ,
2014-01-19 11:38:43 -05:00
hwnd , dxw . IsDesktop ( hwnd ) ? " (DESKTOP) " : " " , lpPaint , lpPaint - > hdc ) ;
2014-11-01 12:38:41 -04:00
// v2.02.53 ...
2014-01-19 11:38:43 -05:00
//if(dxw.IsFullScreen() && dxw.IsDesktop(hwnd)){
if ( dxw . IsFullScreen ( ) ) {
2014-04-22 12:39:07 -04:00
RECT Rect ;
LPRECT lpRect ;
2014-11-01 12:38:41 -04:00
ret = ( * pEndPaint ) ( hwnd , lpPaint ) ;
2015-05-19 12:40:46 -04:00
dxw . lpDDSPrimary - > Unlock ( NULL ) ;
2014-11-01 12:38:41 -04:00
//dxw.ScreenRefresh();
2014-04-22 12:39:07 -04:00
if ( dxw . IsDesktop ( hwnd ) )
lpRect = NULL ;
else {
2014-10-30 12:39:54 -04:00
# if 1
2014-04-22 12:39:07 -04:00
POINT p = { 0 , 0 } ;
lpRect = & Rect ;
( * pGetClientRect ) ( hwnd , lpRect ) ;
p = dxw . ClientOffset ( hwnd ) ;
lpRect - > left + = p . x ;
lpRect - > right + = p . x ;
lpRect - > top + = p . y ;
lpRect - > bottom + = p . y ;
//dxw.AddCoordinates(lpRect, p);
dxw . UnmapClient ( lpRect ) ;
2014-10-30 12:39:54 -04:00
# else
lpRect = & Rect ;
Rect = dxw . MapClientRect ( lpRect ) ;
# endif
2014-04-22 12:39:07 -04:00
}
2015-05-19 12:40:46 -04:00
extBlt ( dxw . lpDDSPrimary , lpRect , dxw . lpDDSPrimary , NULL , 0 , NULL ) ;
2014-11-01 12:38:41 -04:00
return TRUE ;
}
// proxy part ...
ret = ( * pEndPaint ) ( hwnd , lpPaint ) ;
OutTraceDW ( " GDI.EndPaint: hwnd=%x ret=%x \n " , hwnd , ret ) ;
if ( ! ret ) OutTraceE ( " GDI.EndPaint ERROR: err=%d at %d \n " , GetLastError ( ) , __LINE__ ) ;
return ret ;
}
2012-12-24 10:20:23 -05:00
HWND WINAPI extCreateDialogIndirectParam ( HINSTANCE hInstance , LPCDLGTEMPLATE lpTemplate , HWND hWndParent , DLGPROC lpDialogFunc , LPARAM lParamInit )
{
HWND RetHWND ;
isWithinDialog = TRUE ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " CreateDialogIndirectParam: hInstance=%x lpTemplate=%s hWndParent=%x lpDialogFunc=%x lParamInit=%x \n " ,
2012-12-24 10:20:23 -05:00
hInstance , " tbd " , hWndParent , lpDialogFunc , lParamInit ) ;
2013-03-12 12:38:32 -04:00
if ( dxw . IsFullScreen ( ) & & hWndParent = = NULL ) hWndParent = dxw . GethWnd ( ) ;
2012-12-24 10:20:23 -05:00
RetHWND = ( * pCreateDialogIndirectParam ) ( hInstance , lpTemplate , hWndParent , lpDialogFunc , lParamInit ) ;
2014-02-05 11:39:10 -05:00
// v2.02.73: redirect lpDialogFunc only when it is nor NULL
if ( lpDialogFunc ) {
2014-07-13 12:39:33 -04:00
WinDBPutProc ( RetHWND , ( WNDPROC ) lpDialogFunc ) ;
2014-02-05 11:39:10 -05:00
if ( ! ( * pSetWindowLongA ) ( RetHWND , DWL_DLGPROC , ( LONG ) extDialogWindowProc ) )
OutTraceE ( " SetWindowLong: ERROR err=%d at %d \n " , GetLastError ( ) , __LINE__ ) ;
}
2012-12-24 10:20:23 -05:00
2013-12-22 11:38:36 -05:00
OutTraceDW ( " CreateDialogIndirectParam: hwnd=%x \n " , RetHWND ) ;
2012-12-24 10:20:23 -05:00
isWithinDialog = FALSE ;
//if (IsDebug) EnumChildWindows(RetHWND, (WNDENUMPROC)TraceChildWin, (LPARAM)RetHWND);
return RetHWND ;
}
HWND WINAPI extCreateDialogParam ( HINSTANCE hInstance , LPCTSTR lpTemplateName , HWND hWndParent , DLGPROC lpDialogFunc , LPARAM lParamInit )
{
HWND RetHWND ;
isWithinDialog = TRUE ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " CreateDialogParam: hInstance=%x lpTemplateName=%s hWndParent=%x lpDialogFunc=%x lParamInit=%x \n " ,
2012-12-24 10:20:23 -05:00
hInstance , " tbd " , hWndParent , lpDialogFunc , lParamInit ) ;
2013-01-04 10:30:38 -05:00
if ( hWndParent = = NULL ) hWndParent = dxw . GethWnd ( ) ;
2012-12-24 10:20:23 -05:00
RetHWND = ( * pCreateDialogParam ) ( hInstance , lpTemplateName , hWndParent , lpDialogFunc , lParamInit ) ;
2014-02-05 11:39:10 -05:00
// v2.02.73: redirect lpDialogFunc only when it is nor NULL: fix for "LEGO Stunt Rally"
if ( lpDialogFunc ) {
2014-07-13 12:39:33 -04:00
WinDBPutProc ( RetHWND , ( WNDPROC ) lpDialogFunc ) ;
2014-02-05 11:39:10 -05:00
if ( ! ( * pSetWindowLongA ) ( RetHWND , DWL_DLGPROC , ( LONG ) extDialogWindowProc ) )
OutTraceE ( " SetWindowLong: ERROR err=%d at %d \n " , GetLastError ( ) , __LINE__ ) ;
}
2012-12-24 10:20:23 -05:00
2013-12-22 11:38:36 -05:00
OutTraceDW ( " CreateDialogParam: hwnd=%x \n " , RetHWND ) ;
2012-12-24 10:20:23 -05:00
isWithinDialog = FALSE ;
//if (IsDebug) EnumChildWindows(RetHWND, (WNDENUMPROC)TraceChildWin, (LPARAM)RetHWND);
return RetHWND ;
}
BOOL WINAPI extMoveWindow ( HWND hwnd , int X , int Y , int nWidth , int nHeight , BOOL bRepaint )
{
BOOL ret ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " MoveWindow: hwnd=%x xy=(%d,%d) size=(%d,%d) repaint=%x indialog=%x fullscreen=%x \n " ,
2013-07-25 12:38:10 -04:00
hwnd , X , Y , nWidth , nHeight , bRepaint , isWithinDialog , dxw . IsFullScreen ( ) ) ;
2012-12-24 10:20:23 -05:00
2014-02-05 11:39:10 -05:00
if ( dxw . Windowize ) {
if ( dxw . IsDesktop ( hwnd ) ) {
// v2.1.93: happens in "Emergency Fighters for Life" ...
// what is the meaning of this? is it related to video stretching?
OutTraceDW ( " MoveWindow: prevent moving desktop win \n " ) ;
return TRUE ;
}
2012-12-24 10:20:23 -05:00
2014-02-05 11:39:10 -05:00
if ( ( hwnd = = dxw . GethWnd ( ) ) | | ( hwnd = = dxw . hParentWnd ) ) {
OutTraceDW ( " MoveWindow: prevent moving main win \n " ) ;
return TRUE ;
}
2012-12-24 10:20:23 -05:00
2014-02-05 11:39:10 -05:00
if ( dxw . IsFullScreen ( ) ) {
POINT upleft = { 0 , 0 } ;
RECT client ;
BOOL isChild ;
2013-01-04 10:30:38 -05:00
( * pClientToScreen ) ( dxw . GethWnd ( ) , & upleft ) ;
2014-02-05 11:39:10 -05:00
( * pGetClientRect ) ( dxw . GethWnd ( ) , & client ) ;
if ( ( * pGetWindowLongA ) ( hwnd , GWL_STYLE ) & WS_CHILD ) {
isChild = TRUE ;
// child coordinate adjustement
X = ( X * client . right ) / dxw . GetScreenWidth ( ) ;
Y = ( Y * client . bottom ) / dxw . GetScreenHeight ( ) ;
nWidth = ( nWidth * client . right ) / dxw . GetScreenWidth ( ) ;
nHeight = ( nHeight * client . bottom ) / dxw . GetScreenHeight ( ) ;
}
else {
isChild = FALSE ;
// regular win coordinate adjustement
X = upleft . x + ( X * client . right ) / dxw . GetScreenWidth ( ) ;
Y = upleft . y + ( Y * client . bottom ) / dxw . GetScreenHeight ( ) ;
nWidth = ( nWidth * client . right ) / dxw . GetScreenWidth ( ) ;
nHeight = ( nHeight * client . bottom ) / dxw . GetScreenHeight ( ) ;
}
OutTraceDW ( " MoveWindow: DEBUG client=(%d,%d) screen=(%d,%d) \n " ,
client . right , client . bottom , dxw . GetScreenWidth ( ) , dxw . GetScreenHeight ( ) ) ;
OutTraceDW ( " MoveWindow: hwnd=%x child=%x relocated to xy=(%d,%d) size=(%d,%d) \n " ,
hwnd , isChild , X , Y , nWidth , nHeight ) ;
}
else {
if ( ( X = = 0 ) & & ( Y = = 0 ) & & ( nWidth = = dxw . GetScreenWidth ( ) ) & & ( nHeight = = dxw . GetScreenHeight ( ) ) ) {
// evidently, this was supposed to be a fullscreen window....
RECT screen ;
POINT upleft = { 0 , 0 } ;
( * pGetClientRect ) ( dxw . GethWnd ( ) , & screen ) ;
( * pClientToScreen ) ( dxw . GethWnd ( ) , & upleft ) ;
X = upleft . x ;
Y = upleft . y ;
nWidth = screen . right ;
nHeight = screen . bottom ;
OutTraceDW ( " MoveWindow: fixed BIG win pos=(%d,%d) size=(%d,%d) \n " , X , Y , nWidth , nHeight ) ;
}
2012-12-24 10:20:23 -05:00
}
}
ret = ( * pMoveWindow ) ( hwnd , X , Y , nWidth , nHeight , bRepaint ) ;
if ( ! ret ) OutTraceE ( " MoveWindow: ERROR err=%d at %d \n " , GetLastError ( ) , __LINE__ ) ;
return ret ;
}
2013-01-19 11:16:54 -05:00
int WINAPI extShowCursor ( BOOL bShow )
{
static int iFakeCounter ;
int ret ;
2013-04-04 12:17:08 -04:00
OutTraceC ( " ShowCursor: bShow=%x \n " , bShow ) ;
2013-01-19 11:16:54 -05:00
if ( bShow ) {
if ( dxw . dwFlags1 & HIDEHWCURSOR ) {
iFakeCounter + + ;
2013-04-04 12:17:08 -04:00
OutTraceC ( " ShowCursor: HIDEHWCURSOR ret=%x \n " , iFakeCounter ) ;
2013-01-19 11:16:54 -05:00
return iFakeCounter ;
}
}
else {
if ( dxw . dwFlags2 & SHOWHWCURSOR ) {
iFakeCounter - - ;
2013-04-04 12:17:08 -04:00
OutTraceC ( " ShowCursor: SHOWHWCURSOR ret=%x \n " , iFakeCounter ) ;
2013-01-19 11:16:54 -05:00
return iFakeCounter ;
}
}
ret = ( * pShowCursor ) ( bShow ) ;
2013-04-04 12:17:08 -04:00
OutTraceC ( " ShowCursor: ret=%x \n " , ret ) ;
2013-01-19 11:16:54 -05:00
return ret ;
2013-01-27 11:17:04 -05:00
}
2013-10-08 12:38:12 -04:00
BOOL WINAPI extDrawFocusRect ( HDC hDC , const RECT * lprc )
2013-07-21 12:38:09 -04:00
{
return TRUE ;
}
2013-10-08 12:38:12 -04:00
BOOL WINAPI extScrollDC ( HDC hDC , int dx , int dy , const RECT * lprcScroll , const RECT * lprcClip , HRGN hrgnUpdate , LPRECT lprcUpdate )
2013-07-21 12:38:09 -04:00
{
return TRUE ;
2013-10-08 12:38:12 -04:00
}
2013-08-25 12:38:13 -04:00
2013-10-08 12:38:12 -04:00
HWND WINAPI extGetTopWindow ( HWND hwnd )
{
HWND ret ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GetTopWindow: hwnd=%x fullscreen=%x \n " , hwnd , dxw . IsFullScreen ( ) ) ;
2013-10-08 12:38:12 -04:00
// a fullscreen program is supposed to be always top Z-order on the desktop!
ret = ( dxw . IsFullScreen ( ) & & dxw . IsDesktop ( hwnd ) ) ? dxw . GethWnd ( ) : ( * pGetTopWindow ) ( hwnd ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GetTopWindow: ret=%x \n " , ret ) ;
2013-10-08 12:38:12 -04:00
return ret ;
2013-08-25 12:38:13 -04:00
}
LONG WINAPI extTabbedTextOutA ( HDC hdc , int X , int Y , LPCTSTR lpString , int nCount , int nTabPositions , const LPINT lpnTabStopPositions , int nTabOrigin )
{
BOOL res ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " TabbedTextOut: hdc=%x xy=(%d,%d) nCount=%d nTP=%d nTOS=%d str=(%d) \" %s \" \n " ,
2013-08-25 12:38:13 -04:00
hdc , X , Y , nCount , nTabPositions , nTabOrigin , lpString ) ;
if ( dxw . IsFullScreen ( ) & & ( OBJ_DC = = GetObjectType ( hdc ) ) ) {
dxw . MapClient ( & X , & Y ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " TextOut: fixed dest=(%d,%d) \n " , X , Y ) ;
2013-08-25 12:38:13 -04:00
}
res = ( * pTabbedTextOutA ) ( hdc , X , Y , lpString , nCount , nTabPositions , lpnTabStopPositions , nTabOrigin ) ;
return res ;
}
BOOL WINAPI extDestroyWindow ( HWND hWnd )
{
2015-10-05 12:40:44 -04:00
// v2.02.43: "Empire Earth" builds test surfaces that must be destroyed!
// v2.03.20: "Prince of Persia 3D" destroys the main window that must be preserved!
2013-08-25 12:38:13 -04:00
BOOL res ;
OutTraceB ( " DestroyWindow: hwnd=%x \n " , hWnd ) ;
if ( hWnd = = dxw . GethWnd ( ) ) {
2015-10-05 12:40:44 -04:00
if ( dxw . dwFlags6 & NODESTROYWINDOW ) {
OutTraceDW ( " DestroyWindow: do NOT destroy main hwnd=%x \n " , hWnd ) ;
return TRUE ;
}
2013-12-22 11:38:36 -05:00
OutTraceDW ( " DestroyWindow: destroy main hwnd=%x \n " , hWnd ) ;
2013-08-25 12:38:13 -04:00
dxw . SethWnd ( NULL ) ;
}
2014-07-28 12:39:37 -04:00
if ( hControlParentWnd & & ( hWnd = = hControlParentWnd ) ) {
OutTraceDW ( " DestroyWindow: destroy control parent hwnd=%x \n " , hWnd ) ;
hControlParentWnd = NULL ;
}
2013-08-25 12:38:13 -04:00
res = ( * pDestroyWindow ) ( hWnd ) ;
if ( ! res ) OutTraceE ( " DestroyWindow: ERROR err=%d \n " , GetLastError ( ) ) ;
return res ;
}
2014-02-07 11:39:27 -05:00
static char * ExplainTAAlign ( UINT c )
{
static char eb [ 256 ] ;
unsigned int l ;
strcpy ( eb , " TA_ " ) ;
strcat ( eb , ( c & TA_UPDATECP ) ? " UPDATECP+ " : " NOUPDATECP+ " ) ;
strcat ( eb , ( c & TA_RIGHT ) ? ( ( ( c & TA_CENTER ) = = TA_CENTER ) ? " CENTER+ " : " RIGHT+ " ) : " LEFT+ " ) ;
strcat ( eb , ( c & TA_BOTTOM ) ? " BOTTOM+ " : " TOP+ " ) ;
if ( ( c & TA_BASELINE ) = = TA_BASELINE ) strcat ( eb , " BASELINE+ " ) ;
if ( c & TA_RTLREADING ) strcat ( eb , " RTLREADING+ " ) ;
l = strlen ( eb ) ;
eb [ l - 1 ] = 0 ;
return ( eb ) ;
}
static char * ExplainDTFormat ( UINT c )
{
static char eb [ 256 ] ;
unsigned int l ;
strcpy ( eb , " DT_ " ) ;
if ( ! ( c & ( DT_CENTER | DT_RIGHT ) ) ) strcat ( eb , " LEFT+ " ) ;
if ( c & DT_CENTER ) strcat ( eb , " CENTER+ " ) ;
if ( c & DT_RIGHT ) strcat ( eb , " RIGHT+ " ) ;
if ( ! ( c & ( DT_VCENTER | DT_BOTTOM ) ) ) strcat ( eb , " TOP+ " ) ;
if ( c & DT_VCENTER ) strcat ( eb , " VCENTER+ " ) ;
if ( c & DT_BOTTOM ) strcat ( eb , " BOTTOM+ " ) ;
if ( c & DT_WORDBREAK ) strcat ( eb , " WORDBREAK+ " ) ;
if ( c & DT_SINGLELINE ) strcat ( eb , " SINGLELINE+ " ) ;
if ( c & DT_EXPANDTABS ) strcat ( eb , " EXPANDTABS+ " ) ;
if ( c & DT_TABSTOP ) strcat ( eb , " TABSTOP+ " ) ;
if ( c & DT_NOCLIP ) strcat ( eb , " NOCLIP+ " ) ;
if ( c & DT_EXTERNALLEADING ) strcat ( eb , " EXTERNALLEADING+ " ) ;
if ( c & DT_CALCRECT ) strcat ( eb , " CALCRECT+ " ) ;
if ( c & DT_NOPREFIX ) strcat ( eb , " NOPREFIX+ " ) ;
if ( c & DT_INTERNAL ) strcat ( eb , " INTERNAL+ " ) ;
l = strlen ( eb ) ;
eb [ l - 1 ] = 0 ;
return ( eb ) ;
}
2014-04-13 12:39:06 -04:00
BOOL gFixed ;
int WINAPI extDrawTextA ( HDC hdc , LPCTSTR lpchText , int nCount , LPRECT lpRect , UINT uFormat )
{
int ret ;
2014-02-07 11:39:27 -05:00
OutTraceDW ( " DrawText: hdc=%x rect=(%d,%d)-(%d,%d) Format=%x(%s) Text=(%d) \" %s \" \n " ,
hdc , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom , uFormat , ExplainDTFormat ( uFormat ) , nCount , lpchText ) ;
2014-04-13 12:39:06 -04:00
gFixed = TRUE ;
if ( dxw . IsFullScreen ( ) & & ( OBJ_DC = = GetObjectType ( hdc ) ) ) {
dxw . MapClient ( ( RECT * ) lpRect ) ;
OutTraceDW ( " DrawText: fixed rect=(%d,%d)-(%d,%d) \n " , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom ) ;
}
ret = ( * pDrawText ) ( hdc , lpchText , nCount , lpRect , uFormat ) ;
gFixed = FALSE ;
// if nCount is zero, DrawRect returns 0 as text heigth, but this is not an error! (ref. "Imperialism II")
if ( nCount & & ! ret ) OutTraceE ( " DrawText: ERROR ret=%x err=%d \n " , ret , GetLastError ( ) ) ;
return ret ;
}
int WINAPI extDrawTextExA ( HDC hdc , LPTSTR lpchText , int nCount , LPRECT lpRect , UINT dwDTFormat , LPDRAWTEXTPARAMS lpDTParams )
{
int ret ;
OutTraceDW ( " DrawTextEx: hdc=%x rect=(%d,%d)-(%d,%d) DTFormat=%x Text=(%d) \" %s \" \n " ,
hdc , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom , dwDTFormat , nCount , lpchText ) ;
if ( dxw . IsFullScreen ( ) & & ( OBJ_DC = = GetObjectType ( hdc ) ) ) {
dxw . MapClient ( ( RECT * ) lpRect ) ;
OutTraceDW ( " DrawTextEx: fixed rect=(%d,%d)-(%d,%d) \n " , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom ) ;
}
ret = ( * pDrawTextEx ) ( hdc , lpchText , nCount , lpRect , dwDTFormat , lpDTParams ) ;
if ( ! ret ) OutTraceE ( " DrawTextEx: ERROR ret=%x err=%d \n " , ret , GetLastError ( ) ) ;
return ret ;
}
2013-08-25 12:38:13 -04:00
BOOL WINAPI extCloseWindow ( HWND hWnd )
{
2014-03-21 12:38:57 -04:00
// from MSDN: Minimizes (but does not destroy) the specified window.
2013-08-25 12:38:13 -04:00
BOOL res ;
OutTraceB ( " CloseWindow: hwnd=%x \n " , hWnd ) ;
if ( hWnd = = dxw . GethWnd ( ) ) {
2013-12-22 11:38:36 -05:00
OutTraceDW ( " CloseWindow: close main hwnd=%x \n " , hWnd ) ;
2014-03-21 12:38:57 -04:00
// do not delete the reference to main hWnd.
2013-08-25 12:38:13 -04:00
}
res = ( * pCloseWindow ) ( hWnd ) ;
if ( ! res ) OutTraceE ( " CloseWindow: ERROR err=%d \n " , GetLastError ( ) ) ;
return res ;
}
2013-08-30 12:38:14 -04:00
BOOL WINAPI extSetSysColors ( int cElements , const INT * lpaElements , const COLORREF * lpaRgbValues )
{
// v2.02.32: added to avoid SysColors changes by "Western Front"
BOOL ret ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " SetSysColors: Elements=%d \n " , cElements ) ;
2013-08-30 12:38:14 -04:00
if ( dxw . dwFlags3 & LOCKSYSCOLORS ) return TRUE ;
ret = ( * pSetSysColors ) ( cElements , lpaElements , lpaRgbValues ) ;
if ( ! ret ) OutTraceE ( " SetSysColors: ERROR er=%d \n " , GetLastError ( ) ) ;
return ret ;
}
2013-07-09 12:38:16 -04:00
BOOL WINAPI extUpdateWindow ( HWND hwnd )
{
BOOL ret ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " UpdateWindow: hwnd=%x \n " , hwnd ) ;
2013-07-09 12:38:16 -04:00
2014-02-05 11:39:10 -05:00
if ( dxw . Windowize & & dxw . IsRealDesktop ( hwnd ) ) {
2013-12-22 11:38:36 -05:00
OutTraceDW ( " UpdateWindow: remapping hwnd=%x->%x \n " , hwnd , dxw . GethWnd ( ) ) ;
2013-07-09 12:38:16 -04:00
hwnd = dxw . GethWnd ( ) ;
}
ret = ( * pUpdateWindow ) ( hwnd ) ;
if ( ! ret ) OutTraceE ( " UpdateWindow: ERROR er=%d \n " , GetLastError ( ) ) ;
return ret ;
}
2014-07-17 12:39:35 -04:00
BOOL WINAPI extRedrawWindow ( HWND hWnd , const RECT * lprcUpdate , HRGN hrgnUpdate , UINT flags )
{
OutTraceDW ( " RedrawWindow: hwnd=%x flags=%x \n " , hWnd , flags ) ;
return ( * pRedrawWindow ) ( hWnd , lprcUpdate , hrgnUpdate , flags ) ;
}
2013-07-09 12:38:16 -04:00
BOOL WINAPI extGetWindowPlacement ( HWND hwnd , WINDOWPLACEMENT * lpwndpl )
{
BOOL ret ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GetWindowPlacement: hwnd=%x \n " , hwnd ) ;
2013-07-09 12:38:16 -04:00
if ( dxw . IsRealDesktop ( hwnd ) ) {
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GetWindowPlacement: remapping hwnd=%x->%x \n " , hwnd , dxw . GethWnd ( ) ) ;
2013-07-09 12:38:16 -04:00
hwnd = dxw . GethWnd ( ) ;
}
ret = ( * pGetWindowPlacement ) ( hwnd , lpwndpl ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GetWindowPlacement: flags=%x showCmd=%x MinPosition=(%d,%d) MaxPosition=(%d,%d) NormalPosition=(%d,%d)-(%d,%d) \n " ,
2013-07-09 12:38:16 -04:00
lpwndpl - > flags , lpwndpl - > showCmd ,
lpwndpl - > ptMinPosition . x , lpwndpl - > ptMinPosition . y ,
lpwndpl - > ptMaxPosition . x , lpwndpl - > ptMaxPosition . y ,
lpwndpl - > rcNormalPosition . left , lpwndpl - > rcNormalPosition . top , lpwndpl - > rcNormalPosition . right , lpwndpl - > rcNormalPosition . bottom ) ;
switch ( lpwndpl - > showCmd ) {
case SW_SHOW :
if ( dxw . IsFullScreen ( ) ) {
lpwndpl - > showCmd = SW_MAXIMIZE ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " GetWindowPlacement: forcing SW_MAXIMIZE state \n " ) ;
2013-07-09 12:38:16 -04:00
}
break ;
}
if ( ! ret ) OutTraceE ( " GetWindowPlacement: ERROR er=%d \n " , GetLastError ( ) ) ;
return ret ;
}
BOOL WINAPI extSetWindowPlacement ( HWND hwnd , WINDOWPLACEMENT * lpwndpl )
{
BOOL ret ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " SetWindowPlacement: hwnd=%x \n " , hwnd ) ;
2013-07-09 12:38:16 -04:00
if ( dxw . IsRealDesktop ( hwnd ) ) {
2013-12-22 11:38:36 -05:00
OutTraceDW ( " SetWindowPlacement: remapping hwnd=%x->%x \n " , hwnd , dxw . GethWnd ( ) ) ;
2013-07-09 12:38:16 -04:00
hwnd = dxw . GethWnd ( ) ;
}
2013-12-22 11:38:36 -05:00
OutTraceDW ( " SetWindowPlacement: flags=%x showCmd=%x MinPosition=(%d,%d) MaxPosition=(%d,%d) NormalPosition=(%d,%d)-(%d,%d) \n " ,
2013-07-09 12:38:16 -04:00
lpwndpl - > flags , lpwndpl - > showCmd ,
lpwndpl - > ptMinPosition . x , lpwndpl - > ptMinPosition . y ,
lpwndpl - > ptMaxPosition . x , lpwndpl - > ptMaxPosition . y ,
lpwndpl - > rcNormalPosition . left , lpwndpl - > rcNormalPosition . top , lpwndpl - > rcNormalPosition . right , lpwndpl - > rcNormalPosition . bottom ) ;
switch ( lpwndpl - > showCmd ) {
2014-04-13 12:39:06 -04:00
case SW_MAXIMIZE :
2013-07-09 12:38:16 -04:00
if ( dxw . IsFullScreen ( ) ) {
2014-04-13 12:39:06 -04:00
lpwndpl - > showCmd = SW_SHOW ;
OutTraceDW ( " SetWindowPlacement: forcing SW_SHOW state \n " ) ;
2013-07-09 12:38:16 -04:00
}
break ;
}
ret = ( * pSetWindowPlacement ) ( hwnd , lpwndpl ) ;
if ( ! ret ) OutTraceE ( " SetWindowPlacement: ERROR er=%d \n " , GetLastError ( ) ) ;
return ret ;
}
HWND WINAPI extSetCapture ( HWND hwnd )
{
HWND ret ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " SetCapture: hwnd=%x \n " , hwnd ) ;
2013-07-09 12:38:16 -04:00
ret = ( * pSetCapture ) ( hwnd ) ;
2013-12-22 11:38:36 -05:00
OutTraceDW ( " SetCapture: ret=%x \n " , ret ) ;
2013-07-09 12:38:16 -04:00
return ret ;
2013-11-28 11:38:31 -05:00
}
HWND WINAPI extGetActiveWindow ( void )
{
HWND ret ;
ret = ( * pGetActiveWindow ) ( ) ;
2015-01-03 11:40:25 -05:00
if ( dxw . Windowize & & dxw . IsFullScreen ( ) ) {
OutTraceDW ( " GetActiveWindow: ret=%x->%x \n " , ret , dxw . GethWnd ( ) ) ;
return dxw . GethWnd ( ) ;
}
return ret ;
2013-11-28 11:38:31 -05:00
}
HWND WINAPI extGetForegroundWindow ( void )
{
HWND ret ;
ret = ( * pGetForegroundWindow ) ( ) ;
2015-01-03 11:40:25 -05:00
if ( dxw . Windowize & & dxw . IsFullScreen ( ) ) {
OutTraceDW ( " GetForegroundWindow: ret=%x->%x \n " , ret , dxw . GethWnd ( ) ) ;
return dxw . GethWnd ( ) ;
}
return ret ;
2013-12-27 11:38:38 -05:00
}
BOOL WINAPI extIsWindowVisible ( HWND hwnd )
{
BOOL ret ;
ret = ( * pIsWindowVisible ) ( hwnd ) ;
2014-11-01 12:38:41 -04:00
OutTraceB ( " IsWindowVisible: hwnd=%x ret=%x \n " , hwnd , ret ) ;
if ( dxw . IsDesktop ( hwnd ) & & ! ret ) {
2013-12-27 11:38:38 -05:00
OutTraceDW ( " IsWindowVisible: FORCING ret=TRUE \n " ) ;
ret = TRUE ;
}
return ret ;
}
2014-11-01 12:38:41 -04:00
BOOL WINAPI extSystemParametersInfoA ( UINT uiAction , UINT uiParam , PVOID pvParam , UINT fWinIni )
{
BOOL ret ;
2015-07-01 12:40:14 -04:00
OutTraceDW ( " SystemParametersInfoA: Action=%x Param=%x WinIni=%x \n " , uiAction , uiParam , fWinIni ) ;
switch ( uiAction ) {
case SPI_SETKEYBOARDDELAY :
case SPI_SETKEYBOARDSPEED :
OutTraceDW ( " SystemParametersInfoA: bypass action=%x \n " , uiAction ) ;
return TRUE ;
break ;
}
2014-11-01 12:38:41 -04:00
ret = ( * pSystemParametersInfoA ) ( uiAction , uiParam , pvParam , fWinIni ) ;
if ( uiAction = = SPI_GETWORKAREA ) {
LPRECT cli = ( LPRECT ) pvParam ;
2015-02-15 11:40:23 -05:00
* cli = dxw . GetScreenRect ( ) ;
2015-07-01 12:40:14 -04:00
OutTraceDW ( " SystemParametersInfoA: resized client workarea rect=(%d,%d)-(%d,%d) \n " , cli - > left , cli - > top , cli - > right , cli - > bottom ) ;
2014-11-01 12:38:41 -04:00
}
return ret ;
}
2014-02-05 11:39:10 -05:00
BOOL WINAPI extSystemParametersInfoW ( UINT uiAction , UINT uiParam , PVOID pvParam , UINT fWinIni )
{
BOOL ret ;
2015-07-01 12:40:14 -04:00
OutTraceDW ( " SystemParametersInfoW: Action=%x Param=%x WinIni=%x \n " , uiAction , uiParam , fWinIni ) ;
switch ( uiAction ) {
case SPI_SETKEYBOARDDELAY :
case SPI_SETKEYBOARDSPEED :
OutTraceDW ( " SystemParametersInfoW: bypass action=%x \n " , uiAction ) ;
return TRUE ;
break ;
}
2014-02-05 11:39:10 -05:00
ret = ( * pSystemParametersInfoW ) ( uiAction , uiParam , pvParam , fWinIni ) ;
if ( uiAction = = SPI_GETWORKAREA ) {
LPRECT cli = ( LPRECT ) pvParam ;
2015-02-15 11:40:23 -05:00
* cli = dxw . GetScreenRect ( ) ;
2015-07-01 12:40:14 -04:00
OutTraceDW ( " SystemParametersInfoW: resized client workarea rect=(%d,%d)-(%d,%d) \n " , cli - > left , cli - > top , cli - > right , cli - > bottom ) ;
2014-02-05 11:39:10 -05:00
}
return ret ;
}
2014-11-01 12:38:41 -04:00
# undef OutTraceDW
# define OutTraceDW OutTrace
UINT_PTR WINAPI extSetTimer ( HWND hWnd , UINT_PTR nIDEvent , UINT uElapse , TIMERPROC lpTimerFunc )
{
UINT uShiftedElapse ;
UINT_PTR ret ;
// beware: the quicker the time flows, the more the time clicks are incremented,
// and the lesser the pauses must be lasting! Shift operations are reverted in
// GetSystemTime vs. Sleep or SetTimer
uShiftedElapse = dxw . StretchTime ( uElapse ) ;
OutTraceDW ( " SetTimer: hwnd=%x TimerFunc=%x elapse=%d->%d timeshift=%d \n " , hWnd , lpTimerFunc , uElapse , uShiftedElapse , dxw . TimeShift ) ;
ret = ( * pSetTimer ) ( hWnd , nIDEvent , uShiftedElapse , lpTimerFunc ) ;
if ( ret ) dxw . PushTimer ( hWnd , ret , uElapse , lpTimerFunc ) ;
OutTraceDW ( " SetTimer: IDEvent=%x ret=%x \n " , nIDEvent , ret ) ;
return ret ;
}
BOOL WINAPI extKillTimer ( HWND hWnd , UINT_PTR uIDEvent )
{
BOOL ret ;
OutTraceDW ( " KillTimer: hwnd=%x IDEvent=%x \n " , hWnd , uIDEvent ) ;
ret = ( * pKillTimer ) ( hWnd , uIDEvent ) ;
OutTraceDW ( " KillTimer: ret=%x \n " , ret ) ;
2014-02-19 11:38:50 -05:00
if ( ret ) dxw . PopTimer ( hWnd , uIDEvent ) ;
2014-11-01 12:38:41 -04:00
return ret ;
}
2014-03-23 12:38:58 -04:00
BOOL WINAPI extGetUpdateRect ( HWND hWnd , LPRECT lpRect , BOOL bErase )
{
BOOL ret ;
OutTraceDW ( " GetUpdateRect: hwnd=%x Erase=%x \n " , hWnd , bErase ) ;
ret = ( * pGetUpdateRect ) ( hWnd , lpRect , bErase ) ;
if ( ret ) {
OutTraceDW ( " GetUpdateRect: rect=(%d,%d)-(%d,%d) \n " , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom ) ;
if ( dxw . IsFullScreen ( ) ) {
dxw . UnmapClient ( lpRect ) ;
OutTraceDW ( " GetUpdateRect: FIXED rect=(%d,%d)-(%d,%d) \n " , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom ) ;
}
}
else
OutTraceE ( " GetUpdateRect ERROR: err=%d \n " , GetLastError ( ) ) ;
return ret ;
2014-05-14 12:39:12 -04:00
}
BOOL WINAPI extGetCursorInfo ( PCURSORINFO pci )
{
BOOL ret ;
OutTraceDW ( " GetCursorInfo \n " ) ;
ret = ( * pGetCursorInfo ) ( pci ) ;
if ( ret ) {
OutTraceDW ( " GetCursorInfo: flags=%x hcursor=%x pos=(%d,%d) \n " , pci - > flags , pci - > hCursor , pci - > ptScreenPos . x , pci - > ptScreenPos . y ) ;
if ( dxw . IsFullScreen ( ) ) {
dxw . UnmapClient ( & ( pci - > ptScreenPos ) ) ;
OutTraceDW ( " GetCursorInfo: FIXED pos=(%d,%d) \n " , pci - > ptScreenPos . x , pci - > ptScreenPos . y ) ;
}
}
else
OutTraceE ( " GetCursorInfo ERROR: err=%d \n " , GetLastError ( ) ) ;
return ret ;
}
// --- to be hooked ....
HWND WINAPI extWindowFromPoint ( POINT Point )
{
HWND ret ;
OutTraceDW ( " WindowFromPoint: point=(%d,%d) \n " , Point . x , Point . y ) ;
if ( dxw . IsFullScreen ( ) ) {
2015-07-04 12:40:35 -04:00
dxw . UnmapWindow ( & Point ) ;
2014-05-14 12:39:12 -04:00
OutTraceDW ( " WindowFromPoint: FIXED point=(%d,%d) \n " , Point . x , Point . y ) ;
}
ret = ( * pWindowFromPoint ) ( Point ) ;
OutTraceDW ( " WindowFromPoint: hwnd=%x \n " , ret ) ;
return ret ;
}
HWND WINAPI extChildWindowFromPoint ( HWND hWndParent , POINT Point )
{
HWND ret ;
OutTraceDW ( " ChildWindowFromPoint: hWndParent=%x point=(%d,%d) \n " , hWndParent , Point . x , Point . y ) ;
2015-07-04 12:40:35 -04:00
if ( dxw . IsDesktop ( hWndParent ) & & dxw . IsFullScreen ( ) & & dxw . Windowize ) {
2014-05-14 12:39:12 -04:00
dxw . UnmapClient ( & Point ) ;
OutTraceDW ( " ChildWindowFromPoint: FIXED point=(%d,%d) \n " , Point . x , Point . y ) ;
}
ret = ( * pChildWindowFromPoint ) ( hWndParent , Point ) ;
OutTraceDW ( " ChildWindowFromPoint: hwnd=%x \n " , ret ) ;
return ret ;
}
HWND WINAPI extChildWindowFromPointEx ( HWND hWndParent , POINT Point , UINT uFlags )
{
HWND ret ;
OutTraceDW ( " ChildWindowFromPoint: hWndParent=%x point=(%d,%d) flags=%x \n " , hWndParent , Point . x , Point . y , uFlags ) ;
2015-07-04 12:40:35 -04:00
if ( dxw . IsDesktop ( hWndParent ) & & dxw . IsFullScreen ( ) & & dxw . Windowize ) {
2014-05-14 12:39:12 -04:00
dxw . UnmapClient ( & Point ) ;
OutTraceDW ( " ChildWindowFromPointEx: FIXED point=(%d,%d) \n " , Point . x , Point . y ) ;
}
ret = ( * pChildWindowFromPointEx ) ( hWndParent , Point , uFlags ) ;
OutTraceDW ( " ChildWindowFromPointEx: hwnd=%x \n " , ret ) ;
return ret ;
}
2014-02-07 11:39:27 -05:00
BOOL extGetMonitorInfo ( HMONITOR hMonitor , LPMONITORINFO lpmi , GetMonitorInfo_Type pGetMonitorInfo )
{
BOOL res ;
2015-11-03 11:40:28 -05:00
OutTraceDW ( " GetMonitorInfo: hMonitor=%x mi=MONITORINFO%s \n " , hMonitor , lpmi - > cbSize = = sizeof ( MONITORINFO ) ? " " : " EX " ) ;
2014-02-07 11:39:27 -05:00
res = ( * pGetMonitorInfo ) ( hMonitor , lpmi ) ;
2015-03-22 12:40:33 -04:00
//v2.03.15 - must fix the coordinates also in case of error: that may depend on the windowed mode.
if ( dxw . Windowize ) {
2014-02-07 11:39:27 -05:00
OutTraceDW ( " GetMonitorInfo: FIX Work=(%d,%d)-(%d,%d) Monitor=(%d,%d)-(%d,%d) -> (%d,%d)-(%d,%d) \n " ,
lpmi - > rcWork . left , lpmi - > rcWork . top , lpmi - > rcWork . right , lpmi - > rcWork . bottom ,
lpmi - > rcMonitor . left , lpmi - > rcMonitor . top , lpmi - > rcMonitor . right , lpmi - > rcMonitor . bottom ,
0 , 0 , dxw . GetScreenWidth ( ) , dxw . GetScreenHeight ( ) ) ;
lpmi - > rcWork = dxw . GetScreenRect ( ) ;
lpmi - > rcMonitor = dxw . GetScreenRect ( ) ;
2015-03-22 12:40:33 -04:00
res = TRUE ;
2014-02-07 11:39:27 -05:00
}
2015-11-03 11:40:28 -05:00
else
OutTraceE ( " GetMonitorInfo: ERROR err=%d \n " , GetLastError ( ) ) ;
2014-02-07 11:39:27 -05:00
return res ;
}
BOOL WINAPI extGetMonitorInfoA ( HMONITOR hMonitor , LPMONITORINFO lpmi )
{
return extGetMonitorInfo ( hMonitor , lpmi , pGetMonitorInfoA ) ;
}
BOOL WINAPI extGetMonitorInfoW ( HMONITOR hMonitor , LPMONITORINFO lpmi )
{
return extGetMonitorInfo ( hMonitor , lpmi , pGetMonitorInfoW ) ;
}
2014-07-17 12:39:35 -04:00
int WINAPI extGetUpdateRgn ( HWND hWnd , HRGN hRgn , BOOL bErase )
{
int regionType ;
regionType = ( * pGetUpdateRgn ) ( hWnd , hRgn , bErase ) ;
2014-08-29 12:39:42 -04:00
OutTraceDW ( " GetUpdateRgn: hwnd=%x hrgn=%x erase=%x regionType=%x(%s) \n " ,
hWnd , hRgn , bErase , regionType , ExplainRegionType ( regionType ) ) ;
if ( dxw . Windowize & & dxw . IsFullScreen ( ) ) {
if ( regionType = = SIMPLEREGION ) {
RECT rc ;
if ( ! pGetRgnBox ) pGetRgnBox = GetRgnBox ;
regionType = ( * pGetRgnBox ) ( hRgn , & rc ) ;
OutTraceDW ( " GetUpdateRgn: regionType=%x(%s) box=(%d,%d)-(%d,%d) \n " ,
regionType , ExplainRegionType ( regionType ) , rc . left , rc . top , rc . right , rc . bottom ) ;
if ( regionType = = SIMPLEREGION ) {
dxw . UnmapClient ( & rc ) ;
if ( SetRectRgn ( hRgn , rc . left , rc . top , rc . right , rc . bottom ) ) {
// success
OutTraceDW ( " GetUpdateRgn: FIXED box=(%d,%d)-(%d,%d) \n " , rc . left , rc . top , rc . right , rc . bottom ) ;
}
}
}
#if 0
if ( regionType = = COMPLEXREGION ) {
RECT rc ;
if ( ! pGetRgnBox ) pGetRgnBox = GetRgnBox ;
regionType = ( * pGetRgnBox ) ( hRgn , & rc ) ;
OutTraceDW ( " GetUpdateRgn: regionType=%x(%s) box=(%d,%d)-(%d,%d) \n " ,
regionType , ExplainRegionType ( regionType ) , rc . left , rc . top , rc . right , rc . bottom ) ;
if ( regionType = = COMPLEXREGION ) {
//dxw.UnmapClient(&rc);
//if(SetRectRgn(hRgn, rc.left, rc.top, rc.right, rc.bottom )){
if ( SetRectRgn ( hRgn , 0 , 0 , dxw . GetScreenWidth ( ) , dxw . GetScreenHeight ( ) ) ) {
// success
OutTraceDW ( " GetUpdateRgn: FIXED box=(%d,%d)-(%d,%d) \n " , rc . left , rc . top , rc . right , rc . bottom ) ;
}
}
}
# endif
}
return regionType ;
}
2015-03-17 12:40:30 -04:00
# ifdef TRACEPALETTE
UINT WINAPI extGetDIBColorTable ( HDC hdc , UINT uStartIndex , UINT cEntries , RGBQUAD * pColors )
{
UINT ret ;
OutTraceDW ( " GetDIBColorTable: hdc=%x start=%d entries=%d \n " , hdc , uStartIndex , cEntries ) ;
//if((OBJ_DC == GetObjectType(hdc)) && (dxw.dwFlags1 & EMULATESURFACE)){
// //extern PALETTEENTRY PalEntries[256];
// extern DWORD *PaletteEntries;
// if((uStartIndex+cEntries) > 256) cEntries = 256 - uStartIndex;
// for(UINT i=0; i<cEntries; i++) {
// PALETTEENTRY p;
// memcpy(&p, &PaletteEntries[i+uStartIndex], sizeof(DWORD));
// pColors[i].rgbBlue = p.peBlue;
// pColors[i].rgbGreen = p.peGreen;
// pColors[i].rgbRed = p.peRed;
// pColors[i].rgbReserved = p.peFlags;
// }
// ret=cEntries;
//}
//else
// ret = (*pGetDIBColorTable)(hdc, uStartIndex, cEntries, pColors);
ret = ( * pGetDIBColorTable ) ( hdc , uStartIndex , cEntries , pColors ) ;
OutTraceDW ( " GetDIBColorTable: ret=%x \n " , ret ) ;
if ( IsDebug ) dxw . DumpPalette ( cEntries , ( PALETTEENTRY * ) pColors ) ;
return ret ;
}
UINT WINAPI extSetDIBColorTable ( HDC hdc , UINT uStartIndex , UINT cEntries , const RGBQUAD * pColors )
{
UINT ret ;
OutTraceDW ( " SetDIBColorTable: hdc=%x start=%d entries=%d \n " , hdc , uStartIndex , cEntries ) ;
if ( IsDebug ) dxw . DumpPalette ( cEntries , ( PALETTEENTRY * ) pColors ) ;
//if((OBJ_DC == GetObjectType(hdc)) && (dxw.dwFlags1 & EMULATESURFACE)){
// //extern PALETTEENTRY PalEntries[256];
// extern DWORD *PaletteEntries;
// if((uStartIndex+cEntries) > 256) cEntries = 256 - uStartIndex;
// for(UINT i=0; i<cEntries; i++) {
// PALETTEENTRY p;
// memcpy(&p, &PaletteEntries[i+uStartIndex], sizeof(DWORD));
// pColors[i].rgbBlue = p.peBlue;
// pColors[i].rgbGreen = p.peGreen;
// pColors[i].rgbRed = p.peRed;
// pColors[i].rgbReserved = p.peFlags;
// }
// ret=cEntries;
//}
//else
// ret = (*pSetDIBColorTable)(hdc, uStartIndex, cEntries, pColors);
ret = ( * pSetDIBColorTable ) ( hdc , uStartIndex , cEntries , pColors ) ;
OutTraceDW ( " SetDIBColorTable: ret=%x \n " , ret ) ;
return ret ;
}
# endif
2014-08-29 12:39:42 -04:00
# ifdef NOUNHOOKED
BOOL WINAPI extValidateRect ( HWND hWnd , const RECT * lpRect )
{
BOOL ret ;
if ( IsTraceDW ) {
if ( lpRect )
OutTrace ( " ValidateRect: hwnd=%x rect=(%d,%d)-(%d,%d) \n " ,
hWnd , lpRect - > left , lpRect - > top , lpRect - > right , lpRect - > bottom ) ;
else
OutTrace ( " ValidateRect: hwnd=%x rect=NULL \n " , hWnd ) ;
}
ret = ( * pValidateRect ) ( hWnd , lpRect ) ;
return ret ;
}
2014-10-30 12:39:54 -04:00
int WINAPI extGetWindowTextA ( HWND hWnd , LPTSTR lpString , int nMaxCount )
{
// purpose of this wrapped call is to clear the FPS indicator (format " ~ (%d FPS)")
// from the window title, if present. It crashes games such as "Panzer General 3 Scorched Earth"
// when FPS on window title is activated.
int ret ;
OutTraceDW ( " GetWindowTextA: hwnd=%x MaxCount=%d \n " , hWnd , nMaxCount ) ;
ret = ( * pGetWindowTextA ) ( hWnd , lpString , nMaxCount ) ;
if ( ret ) OutTraceDW ( " GetWindowTextA: ret=%d String= \" %s \" \n " , ret , lpString ) ;
if ( ret & & ( dxw . dwFlags2 & SHOWFPS ) & & dxw . ishWndFPS ( hWnd ) ) {
char * p ;
p = strstr ( lpString , " ~ ( " ) ;
if ( p ) {
* p = NULL ;
ret = strlen ( lpString ) ;
OutTraceDW ( " GetWindowTextA: FIXED ret=%d String= \" %s \" \n " , ret , lpString ) ;
}
}
return ret ;
}
# endif
2015-07-04 12:40:35 -04:00
BOOL WINAPI extBringWindowToTop ( HWND hwnd )
{
BOOL res ;
OutTraceDW ( " BringWindowToTop: hwnd=%x \n " , hwnd ) ;
if ( dxw . dwFlags5 & UNLOCKZORDER ) return TRUE ;
res = ( * pBringWindowToTop ) ( hwnd ) ;
return res ;
}
BOOL WINAPI extSetForegroundWindow ( HWND hwnd )
{
BOOL res ;
OutTraceDW ( " SetForegroundWindow: hwnd=%x \n " , hwnd ) ;
if ( dxw . dwFlags5 & UNLOCKZORDER ) return TRUE ;
res = ( * pSetForegroundWindow ) ( hwnd ) ;
return res ;
}
HOOKPROC glpMouseHookProcessFunction ;
HOOKPROC glpMessageHookProcessFunction ;
/*
LRESULT CALLBACK extMouseHookProc ( int code , WPARAM wParam , LPARAM lParam )
{
LRESULT ret ;
OutTrace ( " HookProc intercepted: code=%x wParam=%x lParam=%x \n " , code , wParam , lParam ) ;
MOUSEHOOKSTRUCT * pMouseStruct = ( MOUSEHOOKSTRUCT * ) lParam ;
if ( pMouseStruct ! = NULL ) {
dxw . UnmapWindow ( & ( pMouseStruct - > pt ) ) ;
}
ret = ( * glpMouseHookProcessFunction ) ( code , wParam , lParam ) ;
return ret ;
}
*/
LRESULT CALLBACK extMessageHookProc ( int code , WPARAM wParam , LPARAM lParam )
{
LRESULT ret ;
OutTrace ( " MessageHookProc: code=%x wParam=%x lParam=%x \n " , code , wParam , lParam ) ;
MSG * pMessage = ( MSG * ) lParam ;
ret = NULL ;
if ( pMessage ) {
UINT message = pMessage - > message ;
if ( ( message > = 0x600 ) | | // custom messages
( ( message > = WM_KEYFIRST ) & & ( message < = WM_KEYLAST ) ) ) // keyboard messages
ret = ( * glpMessageHookProcessFunction ) ( code , wParam , lParam ) ;
}
return ret ;
}
HHOOK WINAPI extSetWindowsHookEx ( int idHook , HOOKPROC lpfn , HINSTANCE hMod , DWORD dwThreadId )
{
HHOOK ret ;
if ( dxw . dwFlags5 & EASPORTSHACK ) {
if ( idHook = = WH_MOUSE ) return NULL ;
if ( idHook = = WH_GETMESSAGE ) {
glpMessageHookProcessFunction = lpfn ;
lpfn = extMessageHookProc ;
}
}
ret = ( * pSetWindowsHookEx ) ( idHook , lpfn , hMod , dwThreadId ) ;
return ret ;
}
2015-04-18 12:40:38 -04:00
HRESULT WINAPI extMessageBoxTimeoutA ( HWND hWnd , LPCSTR lpText , LPCSTR lpCaption , UINT uType , WORD wLanguageId , DWORD dwMilliseconds )
{
HRESULT res ;
if ( 1 ) dwMilliseconds = 1000 ;
res = ( * pMessageBoxTimeoutA ) ( hWnd , lpText , lpCaption , uType , wLanguageId , dwMilliseconds ) ;
return res ;
}
HRESULT WINAPI extMessageBoxTimeoutW ( HWND hWnd , LPCWSTR lpText , LPCWSTR lpCaption , UINT uType , WORD wLanguageId , DWORD dwMilliseconds )
{
HRESULT res ;
if ( 1 ) dwMilliseconds = 1000 ;
res = ( * pMessageBoxTimeoutW ) ( hWnd , lpText , lpCaption , uType , wLanguageId , dwMilliseconds ) ;
return res ;
}
2015-04-26 12:40:41 -04:00
BOOL WINAPI extIsIconic ( HWND hWnd )
{
BOOL ret ;
ret = ( * pIsIconic ) ( hWnd ) ;
OutTrace ( " IsIconic: hwnd=%x ret=%x \n " , hWnd , ret ) ;
//return FALSE;
return ret ;
}