WinUI3 : Can a control/window creation through C++ fail? #4019
-
Hi, I'm working on WinUI3 desktop app in CPP. I'm creating the UI programmatically without using XAML like this Window win = Window(); Can this call to window constructor fail? I went through the documentation, but it did not mention anything about this function failing. I also posted this question in MS Q&A - Ref (https://learn.microsoft.com/en-gb/answers/questions/1324279/winui3-can-a-control-window-creation-through-c-fai), where I got to know that this function is newer meant to fail. But in the hypothetical scenario like if no memory is available in system when I create this widget, will the widget creation fail? how is this handled? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Generally, C++/WinRT will use C++ exceptions. So it is usually nice to have a catch block for winrt::hresult_error to handle this. |
Beta Was this translation helpful? Give feedback.
-
@harshith187 Are you initialising the XAML framework correctly? You have to call Application::Start. |
Beta Was this translation helpful? Give feedback.
Generally, C++/WinRT will use C++ exceptions. So it is usually nice to have a catch block for winrt::hresult_error to handle this.