microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.35k stars 678 forks source link

InputNonClientPointerSource no longer works after removing titlebar with SetBorderAndTitleBar #9661

Open HO-COOH opened 5 months ago

HO-COOH commented 5 months ago

Describe the bug

I am trying to completely self-drawing the titlebar buttons, so I use presenter.SetBorderAndTitleBar(false, false); to remove the titlebar together with the caption buttons. Then I found InputNonClientPointerSource to set draggable regions no longer works.

This is an issue for developers trying to completely self-drawing a window.

Steps to reproduce the bug

  1. In window constructor, use this code to completely remove the titlebar (along with the standard caption buttons)
            ExtendsContentIntoTitleBar(true);
            auto presenter = AppWindow().Presenter().as<winrt::Microsoft::UI::Windowing::OverlappedPresenter>();
            presenter.SetBorderAndTitleBar(false, false);
  2. Use this code to set a draggable region
    auto source = winrt::Microsoft::UI::Input::InputNonClientPointerSource::GetForWindowId(winrt::Microsoft::UI::GetWindowIdFromWindow(/*get hwnd from this window*/));
    source.ClearRegionRects(winrt::Microsoft::UI::Input::NonClientRegionKind::Caption);
    source.SetRegionRects(
        winrt::Microsoft::UI::Input::NonClientRegionKind::Caption,
        {
            winrt::Windows::Graphics::RectInt32{
                .X = (int)0,
                .Y = (int)0,
                .Width = (int)400,
                .Height = (int)400
            }
        }
    );

Expected behavior

No response

Screenshots

No response

NuGet package version

Windows App SDK 1.5.3: 1.5.240428000

Packaging type

Packaged (MSIX)

Windows version

Windows 10 version 1809 (17763, October 2018 Update)

IDE

No response

Additional context

No response

github-actions[bot] commented 5 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.