Calling all Windows developers #2622
Replies: 1 comment 3 replies
-
Yes, all Windows App SDK APIs are accessible in C++ (mostly via C++/WinRT).
Yes
No. The best you could get is maybe something that converts your resource scripts to equivalent XAML, either at compile-time or at runtime. There was some discussion in this repo or WinUI 3's but I can't find it at the moment because GitHub search is terrible
WinUI 3 is SDI only AFAIK (the general trend in UI design has been moving away from MDI). However, you can get a TDI (tabbed document interface) using the TabView control. You can also have multiple top level windows.
WinUI 3 is mostly meant as a completely integrated app development framework at the moment. Support for hosting in other code (via XAML islands) is not available yet. But to get the gist of how'd you do it manually, you can simply look at the auto-generated WinMain: int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
{
{
void (WINAPI *pfnXamlCheckProcessRequirements)();
auto module = ::LoadLibrary(L"Microsoft.ui.xaml.dll");
if (module)
{
pfnXamlCheckProcessRequirements = reinterpret_cast<decltype(pfnXamlCheckProcessRequirements)>(GetProcAddress(module, "XamlCheckProcessRequirements"));
if (pfnXamlCheckProcessRequirements)
{
(*pfnXamlCheckProcessRequirements)();
}
::FreeLibrary(module);
}
}
winrt::init_apartment(winrt::apartment_type::single_threaded);
::winrt::Microsoft::UI::Xaml::Application::Start(
[](auto&&)
{
::winrt::make<::winrt::App1::implementation::App>();
});
return 0;
}
You create objects and assign them properties like you'd do with every other C++/WinRT objects. There's a small sample in the cppwinrt repo: https://github.com/kennykerr/cppwinrt/tree/master/Store/XamlCode. While this targets UWP XAML, the same applies to WinUI 3.
Unfortunately the truth is that if a lot of this stuff is not done by the framework, developers will simply not do it. That's how we end up with, for example, apps without high DPI support in 2022.
One does not need to use WinMain to be considered a C++ Windows developer. In fact, many app development frameworks now generally don't have you touching main. Qt and C# WPF are like that. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is the WindowsAppSDK targeting C/C++ Windows Developers?
I've been using Microsoft products for a while; MFC wasn't even flushed out. At the moment I am using the resource compiler and .rc files. I am loading my resources as needed, and most of the time dynamically create them using C++ code to make sure the program will run in case a resource DLL isn't found. Most of the time (99%) I handcraft my .rc files too. Would this qualify as a Windows Developer under your definition?
The generated UI elements from WinUI 2 and WinUI 3 look good but the XAML implementation is terrible. Any chance the resource compiler can generate the same UI elements?
Looking at some of the windowing discussions I am a little confused. Are you discussing SDI or MDI type windows?
Is the design and implementation limiting that? That strikes me as alarming, but I don't know enough to be honest.
The Visual Studio 2022 templates are sparse and samples such as Mica cpp-win32 are lacking. C/C++ templates should have a WinMain, and samples that show how to create the UI elements via code.
Please get rid of any WinMain hidden in another file covered by an ifndef
Please remove anything that is not CRT based. In other words, please list what we need to call to get the UI engine up and running.
Please provide samples that show how to create the various UI elements in code.
From a Windows Developer perspective this makes sense. Please don't automagically perform startup stuff - let us call what is needed.
I get the vibe of XAML and C# developers with the examples I see and the startup code. I don't care for XAML - it is poorly done - and this is C/C++ WinMain developers. If not, my apologies.
Beta Was this translation helpful? Give feedback.
All reactions