You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using InputNonClientPointerSource to set the maximize button region of a win32 window (created with CreateWindow), but it secretly reverts back to default 32px width and position when the window is activated the second time. This event can even be caught using RegionsChanged event.
Steps to reproduce the bug
Create a normal win32 window
static HWND CreateWin32Window()
{
constwchar_t CLASS_NAME[] = L"Sample Window Class";
WNDCLASS wc = {};
wc.lpfnWndProc = WindowProc; // Pointer to the window procedure
wc.lpszClassName = CLASS_NAME; // Window class name// Register the window classRegisterClass(&wc);
// Create the window
HWND hwnd = CreateWindowEx(
0, // Optional window styles
CLASS_NAME, // Window classL"Sample Window", // Window text
WS_OVERLAPPEDWINDOW, // Window style// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, // Parent windowNULL, // MenuNULL, // Instance handleNULL// Additional application data
);
ShowWindow(hwnd, SW_SHOW);
return hwnd;
}
Set the region
auto hwnd = CreateWin32Window();
auto windowId = winrt::Microsoft::UI::GetWindowIdFromWindow(hwnd);
auto appWindow = winrt::Microsoft::UI::Windowing::AppWindow::GetFromWindowId(windowId);
appWindow.TitleBar().ExtendsContentIntoTitleBar(true);
auto pointerSource = winrt::Microsoft::UI::Input::InputNonClientPointerSource::GetForWindowId(windowId);
pointerSource.SetRegionRects(
winrt::Microsoft::UI::Input::NonClientRegionKind::Maximize,
{
winrt::Windows::Graphics::RectInt32
{
.X = 0,
.Y = 0,
.Width = 100,
.Height = 100
}
}
);
pointerSource.RegionsChanged([](
winrt::Microsoft::UI::Input::InputNonClientPointerSource const& source,
winrt::Microsoft::UI::Input::NonClientRegionsChangedEventArgs const& arg)
{
// filters the Maximize region changeif (auto regions = arg.ChangedRegions();
std::ranges::find(regions, winrt::Microsoft::UI::Input::NonClientRegionKind::Maximize) != regions.end())
{
auto changedRegions = source.GetRegionRects(winrt::Microsoft::UI::Input::NonClientRegionKind::Maximize);
for (auto region : changedRegions)
{
OutputDebugString(std::format(L"X: {}, Y: {}, Width: {}, Height: {}\n", region.X, region.Y, region.Width, region.Height).data()); // see this message!
}
}
});
Expected behavior
No response
Screenshots
No response
NuGet package version
Windows App SDK 1.6.3: 1.6.250108002
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 24H2 (22621, October 2024 Update)
Describe the bug
I am using
InputNonClientPointerSource
to set the maximize button region of a win32 window (created withCreateWindow
), but it secretly reverts back to default 32px width and position when the window is activated the second time. This event can even be caught usingRegionsChanged
event.Steps to reproduce the bug
Expected behavior
No response
Screenshots
No response
NuGet package version
Windows App SDK 1.6.3: 1.6.250108002
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 24H2 (22621, October 2024 Update)
IDE
Visual Studio 2022
Additional context
Repro, build and click the button to see.
The text was updated successfully, but these errors were encountered: