-
Notifications
You must be signed in to change notification settings - Fork 674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: is there no API exposed to manipulate the WinUIDesktopWin32WindowClass window size? #2564
Comments
There is a Window element, but with Win32 it links to the HWND, and with UWP it links to the CoreWindow. The future direction and capabilities of Windowing is an ongoing topic, and Win32 enables you to go into the HWND, but UWP doesn't allow this. |
Is there an abstraction over the two to set the window size? |
This is the spec as it is being developed AFAICT |
Thanks. I see it has this
I guess I should open an issue there? Because without additional APIs to support the Win32 case, there's a disparity in how much control the two different window modes give the application/developer (and ironically, uwp is giving more control than win32 in this case). Then again, the entire |
@marb2000 as FYI |
In Preview 1 there is not an API that allows you to set the window size for Desktop. It's planned for future previews (TBD yet). If you want to change the Window's size you can use Win32 APIs. For example using the SetWindowPos: [DllImport("user32.dll", SetLastError = true)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags); Then you can move it using the flag SWP_SHOWWINDOW int HWND_TOP = 0;
int SWP_SHOWWINDOW = 0x0040;
SetWindowPos(windowHandle, (IntPtr)HWND_TOP, position_x, position_y, window_width, window_height,SWP_SHOWWINDOW); To get Window Handle you can you use the IWindowNative COM interface that I used in my //Build demo: Window window = new MainWindow();
WindowWrapper windowWrapper = WindowWrapper.FromAbi(window.ThisPtr);
IntPtr windowHandle = windowWrapper.WindowHandle; Hope this helps meanwhile. |
Thanks, @marb2000 both for the future API info and especially for the Note that it seems you must first activate the window or else XamlUdk will throw an exception on the call, which is unfortunate because it means that there's a flash of the wrong window size before it gets set correctly. |
2023 and still no such feature in sight? |
You may want to explore the new |
For a C#/Win32 project using XAML Islands to host WinUI 3, there does not seem to be any API that I can find for interacting with the parent window? e.g. without manually obtaining the hWnd and using the native api, it seems that you have access to the "fake" CoreWindow but no access to the actual top-level Window.
For example, with ApplicationView.SetPreferredMinSize and ApplicationView.TryResizeView not working, I wanted to work around it by manually setting the window size. While XamlRoot can be used to get the content size, it can't be used to set it.
The text was updated successfully, but these errors were encountered: