question

RebekaFox-7509 avatar image
0 Votes"
RebekaFox-7509 asked RebekaFox-7509 commented

App::Window Size on Launch

Without the old XAML editor I can't set the startup size of the App::Window in C++/WinRT WinUI 3.0 Desktop. I can get the Bounds(), I can set the Content().Measure(mSize);

 void App::OnLaunched(LaunchActivatedEventArgs const& e)
 {    
     oWindow = make<HV3DRoot>();
    
     oWindow.Content().Measure(Size{ 1550,800 });
    
     oWindow.Activate();
    
    
 }

but I can't set the App starting window size. How would I start fullscreen? Why is content size 1550 x 800 and not closer to 1920 x (1080p)?

windows-app-sdk
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Castorix31 avatar image
0 Votes"
Castorix31 answered RebekaFox-7509 commented

How would I start fullscreen?

Use
AppWindow.Show
then
AppWindow.SetPresenter with AppWindowPresenterKind.FullScreen
(in MainWindow constructor for example)
or
AppWindow.Resize for any size
(tested on Windows 10 21H1)


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Well it took quite a bit more than this but my main issue was that I was unaware of AppWindow, and there was some screwing around with the hWnd and WindowID functions . . .. the following works for me:

     oWindow = make<HV3DRoot>();
     oWindow.Activate();
    
     HWND hWnd{ nullptr };
     winrt::check_hresult(oWindow.as<IWindowNative>()->get_WindowHandle(&hWnd));
        
     WindowId oWindowId{};        
     oWindowId = GetWindowIdFromWindow(hWnd);
    
     AppWindow oAppWindow = AppWindow::GetFromWindowId(oWindowId);
    
     oAppWindow.Resize(winrt::Windows::Graphics::SizeInt32{ 1800,800 });
    
 }



0 Votes 0 ·