dotMorten / WinUIEx

WinUI Extensions
https://dotmorten.github.io/WinUIEx
MIT License
602 stars 38 forks source link

Extension to Add the min height and width #6

Closed MarkBQE closed 2 years ago

MarkBQE commented 3 years ago

Extension to control min height and width will be a good one to add.

https://github.com/microsoft/microsoft-ui-xaml/issues/2945

fourdragons commented 2 years ago

Apologies for the somewhat off-topic comment, but I just had to say THANK YOU! Both to dotMorten (for doing this), and to MarkBQE for mentioning the issue that brought me here! Now, if only I had discovered this say, oh, two days ago! I just spent the last two days (duplicating?) some of your work here. Nice to see I'm not the only one that thinks WinUI 3 is missing just a few things right now.

dotMorten commented 2 years ago

@fourdragons Thank you for the kind words. Much appreciated.

dotMorten commented 2 years ago

For reference UWP equivalent: https://docs.microsoft.com/en-us/uwp/api/windows.ui.windowmanagement.preview.windowmanagementpreview.setpreferredminsize?view=winrt-22000#Windows_UI_WindowManagement_Preview_WindowManagementPreview_SetPreferredMinSize_Windows_UI_WindowManagement_AppWindow_Windows_Foundation_Size_

Looks like being able to do this requires listening for WM Messages and inspecting https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-minmaxinfo

dotMorten commented 2 years ago

The WindowEx class now has MinWidth and MinHeight properties, If you don't want to use the custom window class, you can use the new message monitor to do the same thing WindowEx is doing: https://github.com/dotMorten/WinUIEx/blob/cd395e2c451df7eb431d4f522eadbe5e5e72f498/src/WinUIEx/WindowEx.cs#L66-L94

IndianaGary commented 2 years ago

Hi Morten,

Thank you for implementing this! It also raises a question: does WinUIEx make it possible to determine which MONITOR a particular Window is on? Or is this something I can straightforwardly implement myself. My Win32 is a bit rusty ATM.

Regards,

Gary

dotMorten commented 2 years ago

Use this to get a list of Monitors: https://dotmorten.github.io/WinUIEx/api/WinUIEx.MonitorInfo.GetDisplayMonitors.html#WinUIEx_MonitorInfo_GetDisplayMonitors Then use the PositionChanged event to determine what monitor the window intersects the most.

IndianaGary commented 2 years ago

Perfect! Thanks for the help!

Gary

From: Morten Nielsen @.> Sent: Thursday, January 6, 2022 7:19 PM To: dotMorten/WinUIEx @.> Cc: Gary Lewis @.>; Comment @.> Subject: Re: [dotMorten/WinUIEx] Extension to Add the min height and width (#6)

Use this to get a list of Monitors: https://dotmorten.github.io/WinUIEx/api/WinUIEx.MonitorInfo.GetDisplayMonito rs.html#WinUIEx_MonitorInfo_GetDisplayMonitors https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdotmorten. github.io%2FWinUIEx%2Fapi%2FWinUIEx.MonitorInfo.GetDisplayMonitors.html%23Wi nUIEx_MonitorInfo_GetDisplayMonitors&data=04%7C01%7C%7Cb4dc529ab5a0436899d20 8d9d18c6c32%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637771223303968781% 7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwi LCJXVCI6Mn0%3D%7C3000&sdata=cRVct1bt8knQT5gPFPaEjPmbgQkofxJgzCh7ftgZWi0%3D&r eserved=0 Then use the PositionChanged event to determine what monitor the window intersects the most.

- Reply to this email directly, view it on GitHub https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com %2FdotMorten%2FWinUIEx%2Fissues%2F6%23issuecomment-1007109145&data=04%7C01%7 C%7Cb4dc529ab5a0436899d208d9d18c6c32%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1% 7C0%7C637771223303978741%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjo iV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=7aTSyaeT5NVsYAuhZ5dATEF UYQF6Y2woNnTB%2BmDU0GY%3D&reserved=0 , or unsubscribe https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com %2Fnotifications%2Funsubscribe-auth%2FADFAH7EJSPMWFJKANFGANPLUUZLRRANCNFSM45 4EJZXA&data=04%7C01%7C%7Cb4dc529ab5a0436899d208d9d18c6c32%7C84df9e7fe9f640af b435aaaaaaaaaaaa%7C1%7C0%7C637771223303978741%7CUnknown%7CTWFpbGZsb3d8eyJWIj oiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=TX 3%2BbNYGBSbNb9wXPDkv2BG58uxzHMaefKfplpRR7os%3D&reserved=0 . You are receiving this because you commented. https://github.com/notifications/beacon/ADFAH7ADRRXANLOYQQ3EXN3UUZLRRA5CNFS M454EJZXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHQDUIGI .gif Message ID: @. @.> >