I'm interested in overriding the entry point in my WinUI 3.0 Desktop App to control the message pump. It doesn't appear to be as simple as redefining the static function
static auto Start(winrt::Microsoft::UI::Xaml::ApplicationInitializationCallback const& callback);
in the applications child class. I'm a bit confused even, if the entry point isn't still wWinMain, because if it is, it isn't defined in the solution. I haven't tried setting the Linker option to some other entry point, because I saw mentioned that doing so skips static member pre-processing, and I figured I'd find out what that meant before I started messing around. So how do I capture the entry point?
CodePudding user response:
This has probably been generated by the tooling you use. If you don't use any special tooling or/and have chosen a fancy compiler, you should be able to do it yourself.
If you choose Microsoft tooling, typically
And add for example this to your appp.xaml.cpp file:
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nShowCmd)
{
winrt::init_apartment(winrt::apartment_type::single_threaded);
// put your fancy code somewhere here
::winrt::Microsoft::UI::Xaml::Application::Start(
[](auto&&)
{
// and here (default is like this)
// ::winrt::make<::winrt::MyNamespace::MyApp::implementation::App>();
});
return 0;
}