diff --git a/reactos/include/wine/setupapi.h b/reactos/include/wine/setupapi.h index 86337a5fb17..94ada2083d6 100644 --- a/reactos/include/wine/setupapi.h +++ b/reactos/include/wine/setupapi.h @@ -675,6 +675,7 @@ LONG WINAPI AddTagToGroupOrderList(PCWSTR, DWORD, DWORD); VOID WINAPI AssertFail(LPSTR, UINT, LPSTR); DWORD WINAPI CaptureAndConvertAnsiArg(PCSTR lpSrc, PWSTR *lpDst); DWORD WINAPI CaptureStringArg(PCWSTR lpSrc, PWSTR *lpDst); +VOID WINAPI CenterWindowRelativeToParent(HWND); BOOL WINAPI ConcatenatePaths(LPWSTR, LPCWSTR, DWORD, LPDWORD); BOOL WINAPI DelayedMove(PCWSTR lpExistingFileName, PCWSTR lpNewFileName); BOOL WINAPI DoesUserHavePrivilege(PCWSTR lpPrivilegeName); diff --git a/reactos/lib/setupapi/misc.c b/reactos/lib/setupapi/misc.c index fe9189b8cd6..5ff66c99e19 100644 --- a/reactos/lib/setupapi/misc.c +++ b/reactos/lib/setupapi/misc.c @@ -860,7 +860,7 @@ VOID WINAPI AssertFail(LPSTR lpFile, UINT uLine, LPSTR lpMessage) CHAR szModule[MAX_PATH]; CHAR szBuffer[2048]; LPSTR lpName; - LPSTR lpBuffer; +// LPSTR lpBuffer; TRACE("%s %u %s\n", lpFile, uLine, lpMessage); @@ -1044,3 +1044,49 @@ ConcatenatePaths(LPWSTR lpPath, return (dwBufferSize >= dwTotalSize); } + + +/************************************************************************** + * CenterWindowRelativeToParent [SETUPAPI.@] + * + * Centers a window relative to its parent. + * + * PARAMS + * hwnd [I] Window to center. + * + * RETURNS + * None + */ +VOID WINAPI +CenterWindowRelativeToParent(HWND hwnd) +{ + HWND hwndOwner; + POINT ptOrigin; + RECT rcWindow; + RECT rcOwner; + INT nWindowWidth, nWindowHeight; + INT nOwnerWidth, nOwnerHeight; + INT posX, posY; + + hwndOwner = GetWindow(hwnd, GW_OWNER); + if (hwndOwner == NULL) + return; + + ptOrigin.x = 0; + ptOrigin.y = 0; + ClientToScreen(hwndOwner, &ptOrigin); + + GetWindowRect(hwnd, &rcWindow); + GetClientRect(hwndOwner, &rcOwner); + + nWindowWidth = rcWindow.right - rcWindow.left; + nWindowHeight = rcWindow.bottom - rcWindow.top; + + nOwnerWidth = rcOwner.right - rcOwner.left; + nOwnerHeight = rcOwner.bottom - rcOwner.top; + + posX = ((nOwnerWidth - nWindowWidth) / 2) + ptOrigin.x; + posY = ((nOwnerHeight - nWindowHeight) / 2) + ptOrigin.y; + + MoveWindow(hwnd, posX, posY, nWindowHeight, nWindowWidth, 0); +} diff --git a/reactos/lib/setupapi/setupapi.spec b/reactos/lib/setupapi/setupapi.spec index 42c19fff93b..bfa968c875e 100644 --- a/reactos/lib/setupapi/setupapi.spec +++ b/reactos/lib/setupapi/setupapi.spec @@ -192,7 +192,7 @@ @ stub CM_Unregister_Device_Interface_ExW @ stdcall CaptureAndConvertAnsiArg(str ptr) @ stdcall CaptureStringArg(wstr ptr) -@ stub CenterWindowRelativeToParent +@ stdcall CenterWindowRelativeToParent(long) @ stdcall ConcatenatePaths(wstr wstr long ptr) @ stdcall DelayedMove(wstr wstr) @ stub DelimStringToMultiSz diff --git a/reactos/w32api/include/setupapi.h b/reactos/w32api/include/setupapi.h index 97bea01d3f3..8792b69460d 100644 --- a/reactos/w32api/include/setupapi.h +++ b/reactos/w32api/include/setupapi.h @@ -1038,6 +1038,7 @@ typedef SP_BACKUP_QUEUE_PARAMS_A SP_BACKUP_QUEUE_PARAMS, WINSETUPAPI LONG WINAPI AddTagToGroupOrderList(PCWSTR, DWORD, DWORD); +WINSETUPAPI VOID WINAPI CenterWindowRelativeToParent(HWND); WINSETUPAPI PWSTR WINAPI DuplicateString(PCWSTR); WINSETUPAPI BOOL WINAPI IsUserAdmin(VOID); WINSETUPAPI VOID WINAPI MyFree(PVOID);