MCPcopy Create free account
hub / github.com/DiscordMessenger/dm / CenterWindow

Function CenterWindow

src/windows/WinUtils.cpp:1396–1412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1394}
1395
1396void CenterWindow(HWND hWnd, HWND hRelativeTo)
1397{
1398 RECT rect1, rect2;
1399 GetWindowRect(hWnd, &rect1);
1400 GetWindowRect(hRelativeTo, &rect2);
1401
1402 OffsetRect(&rect1, -rect1.left, -rect1.top);
1403 int width = rect1.right - rect1.left, height = rect1.bottom - rect1.top;
1404
1405 OffsetRect(
1406 &rect1,
1407 (rect2.left + rect2.right) / 2 - (rect1.right - rect1.left) / 2,
1408 (rect2.top + rect2.bottom) / 2 - (rect1.bottom - rect1.top) / 2
1409 );
1410
1411 MoveWindow(hWnd, rect1.left, rect1.top, rect1.right - rect1.left, rect1.bottom - rect1.top, TRUE);
1412}
1413
1414#ifndef MINGW_SPECIFIC_HACKS
1415#include <mutex>

Callers 2

UploadDialogProcFunction · 0.85
DlgProcMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected