/* You can also use project link settings to explicitly link WindowsApp.lib.
Or, you can do it in source code (in pch.h, for example) like this. */
#pragma comment(lib, "windowsapp")
/* To use Windows Runtime (WinRT) APIs in your Win32 app, we use C++/WinRT.
The Windows SDK headers are the Windows Runtime ABI header files */
#include <windows.foundation.h>
#include <windows.ui.composition.interop.h>
/* all it takes to cause winrt::implements to support classic COM interfaces
is to include the unknwn.h header file before you include any C++/WinRT headers
You could do that explicitly, or indirectly by including some other header file
such as ole2.h. One recommended method is to include the wil\cppwinrt.h header
file, which is part of the Windows Implementation Libraries (WIL).
The wil\cppwinrt.h header file not only makes sure that unknwn.h is included
before winrt/base.h, it also sets things up so that C++/WinRT and WIL understand
each other's exceptions and error codes.
You can then as<> for classic COM interfaces, and the example code will compile */
#include <unknwn.h>
//#include <wil\cppwinrt.h>
/* include C++/WinRT headers */
#include <winrt/base.h>
#include "winrt/Windows.Foundation.h"
#include <winrt/Windows.UI.Composition.Desktop.h>
//#include <winrt/Windows.UI.Composition.h>
//#include <winrt/Windows.UI.Core.h>
#include <DispatcherQueue.h>
#include <presentation.h>
#pragma comment(lib, "dcomp.lib")
/* using namespace aliases for the different islands to deal with otherwise
potential namespace collisions between the C++/WinRT projection and the ABI. */
namespace winrt {
using namespace winrt::Windows::System;
using namespace winrt::Windows::UI;
using namespace winrt::Windows::UI::Core;
using namespace winrt::Windows::UI::Composition;
using namespace winrt::Windows::UI::Composition::Desktop;
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::Foundation::Numerics;
}
/* ABI types found in the SDK header
Windows::Foundation, and all other Windows namespaces, are
declared by the SDK headers within the ABI namespace */
namespace abi {
/* SDK Application Binary Interface, or ABI */
using namespace ABI::Windows::System;
using namespace ABI::Windows::UI;
using namespace ABI::Windows::UI::Composition;
using namespace ABI::Windows::UI::Composition::Desktop;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::Foundation::Numerics;
}
I'm using HelloComposition example, and getting errors on the code in the AddCompositionElement
function.
The first line of code in the function, auto visuals = m_DesktopWindowTarget.Root().as<abi::ContainerVisual>().Children();
returns these errors:
'ABI::Windows::UI::Composition::ContainerVisual': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_base_of'
'ABI::Windows::UI::Composition::ContainerVisual': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_base_of'
'ABI::Windows::UI::Composition::ContainerVisual': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_base_of'
'ABI::Windows::UI::Composition::ContainerVisual': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_base_of'
'ABI::Windows::UI::Composition::ContainerVisual': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_base_of'
use of undefined type 'ABI::Windows::UI::Composition::ContainerVisual'
'void': all return expressions must deduce to the same type: previously it was 'T'
use of undefined type 'ABI::Windows::UI::Composition::ContainerVisual'
'void': all return expressions must deduce to the same type: previously it was 'T'
use of undefined type 'ABI::Windows::UI::Composition::ContainerVisual'
use of undefined type 'ABI::Windows::UI::Composition::ContainerVisual'