MCPcopy Create free account
hub / github.com/HO-COOH/FastCopy / CenterWindow

Function CenterWindow

FastCopy/WindowHelper.cpp:35–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35void CenterWindow(winrt::Microsoft::UI::Xaml::Window window, winrt::Windows::Graphics::SizeInt32 size)
36{
37 auto const monitorInfo = MonitorInfo::GetPrimary();
38 auto const dpi = GetDpiForWindow(GetHwnd(window));
39 MoveAndResizeWindow(window,
40 {
41 .X = (monitorInfo.rcWork.right - monitorInfo.rcWork.left - ScaleForDpi(size.Width, dpi)) / 2,
42 .Y = (monitorInfo.rcWork.bottom - monitorInfo.rcWork.top - ScaleForDpi(size.Height, dpi)) / 2,
43 .Width = size.Width,
44 .Height = size.Height
45 });
46}
47
48void ResizeWindow(winrt::Microsoft::UI::Xaml::Window window, winrt::Windows::Graphics::SizeInt32 size)
49{

Callers 1

CopyDialogWindowMethod · 0.85

Calls 3

GetHwndFunction · 0.85
MoveAndResizeWindowFunction · 0.85
ScaleForDpiFunction · 0.85

Tested by

no test coverage detected