Is it possible to create window using C++/WinRT from a console application?

0

When using Win32 API, it's not really necessary to have a winmain entry point in order to create a window, because we can still call RegisterClassExW and CreateWindowExW, etc. I wonder if it's possible to do so as well in creating a C++/WinRT window, since almost every example on the Internet is using template projects.

I tried to create a struct which inherits implements<App, IFrameworkView, IFrameworkViewSource> with all necessary functions (Initialize, Uninitialize, Load, SetWindow, Run, etc.), then call CoreApplication::Run(winrt::make<App>()) inside int main(), but WinRT either complains about not having run init_apartment() beforehand, or shows a weird error as WinRT originate error - 0x80070057 : 'serverName' and that HRESULT is E_INVALIDARG, and that a hresult_invalid_argument(take_ownership_from_abi) is thrown. Plus, the source file created with template project doesn't even have to run init_apartment() first, which I couldn't really understand why.

Is it possible to create a C++/WinRT window from a console application? Thanks.

c++
windows-runtime
c++-winrt
asked on Stack Overflow Jan 18, 2020 by Gary C.

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0