1

I am working on the WinUI3 desktop application with C++. I discovered how windows significantly allow us to customize the title bar in this link. But it also said, it will reserve the Top Right/Top Left corner for the Min, Max, and Close buttons which windows will handle.

So as we cannot remove Min, Max, and close button when Window.ExtendsContentIntoTitleBar is set to true , I came across AppWindowTitleBar.ExtendsContentIntoTitleBar Property. By setting AppWindowTitleBar.ExtendsContentIntoTitleBar to true, i was able to remove min max buttons with title bar customization

SetWindowLong(hwnd, GWL_STYLE,GetWindowLong(hwnd, GWL_STYLE) & ~(WS_MINIMIZEBOX | WS_MAXIMIZEBOX));

enter image description here Here in the above image, I have set Canvas as the Window titlebar, and this canvas has different widgets like textbox, button, etc. But the issue here is, I am not able to perform a mouse click on the titlebar area, I am not able to get a pointer-pressed event, or can't get focus on a textbox on the mouse click, but I'm able to get focus on a textbox on tab press.

It would of great help if you could help me with getting mouse events on the window title bar with window customized with AppWindowTitleBar.ExtendsContentIntoTitleBar.

Thank you

Harshith
  • 181
  • 2
  • 9
  • I suggest you could refer to the similar thread: https://learn.microsoft.com/en-us/answers/questions/1190588/winui3-how-to-remove-min-max-close-button-with-tit You could try to use` SetBorderAndTitleBar`, with transparency (layered window) and PointerMoved and others to move the window. – Jeaninez - MSFT Apr 05 '23 at 02:08
  • @Jeaninez-MSFT, I have referred to that page and using SetBorderAndTitleBar works fine, but i wanted to do with default window title bar so that i wont have to handle window resize and caption button, as i was able to remove some caption buttons, now only problem is i am not able to perform mouse operations on the UIElement which is under title bar area, Did i miss something here while customizing the titlebar? – Harshith Apr 05 '23 at 05:10
  • If you add interactive content in the title bar area, you should define explicit drag regions around that content so that users can interact with it. You could try to use [AppWindowTitleBar.SetDragRectangles(RectInt32[]) Method](https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindowtitlebar.setdragrectangles?view=windows-app-sdk-1.2) to set the drag regions. You could refer to the Doc: [Interactive content](https://learn.microsoft.com/en-us/windows/apps/develop/title-bar?tabs=wasdk#interactive-content) – Jeaninez - MSFT Apr 05 '23 at 07:31

1 Answers1

1

If you add interactive content in the title bar area, you should define explicit drag regions around that content so that users can interact with it.

You could try to use AppWindowTitleBar.SetDragRectangles to set the drag regions.

I suggest you could refer to the Doc: Interactive content

Jeaninez - MSFT
  • 3,210
  • 1
  • 5
  • 20