Category : c++-winrt

I’m using WinRT for showing ToastNotification. While working on this, I stumbled across the more generic problem that when a class factor is registered via ::CoRegisterClassObject( callbackGuid, winrt::make<NotificationCallbackFactory>().get(), CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE, &registration)) from a server process running with admin rights, a client process running with normal rights cannot instantiate it. The call CoCreateInstanceEx(callbackGuid, NULL, CLSCTX_LOCAL_SERVER, pcsi, ..

Read more

I’m trying to find a sample project for exporting a COM object from WinRT / C++. Microsoft provides the Toast sample for out-of-process servers, but there are no good samples for in-process servers. My goal is to implement IWTSPlugin as per https://docs.microsoft.com/en-us/windows/win32/termserv/dvc-plug-in-registration . I’m trying to conjure up a DLL that I can install via ..

Read more

Is there a way I can directly sort a winrt::Windows::Foundation::Collections::IObservableVector<T> without creating a new vector nor converting it to a std::vector<T>? IObservableVector<int> numbers{ single_threaded_observable_vector<int>() }; numbers.Append(5); numbers.Append(1); numbers.Append(3); std::sort(numbers.begin(), numbers.end()); The std::sort seems not to work on C++/WinRT collections, at least for me. My further goal is to display sorted and filtered collection of complex ..

Read more

I am showing toast notofication with couple of actions "Dismiss", "Open". I have added a activated callback for my toast. When I activate(click on toast and not on any action button) my callback OnToastActivated gets invoked as expected. However when I click any button my handler OnToastActivated isn’t invoked. Am I missing anything here? Do ..

Read more

I’m having a problem with creating a static event in a C++/WinRT UWP application. The code below compiles successfully when the static keyword is removed. // MainPage.idl static event Windows.Foundation.EventHandler<Int32> MyEvent; // MainPage.h static event_token MyEvent(Windows::Foundation::EventHandler<int32_t> const&); static void MyEvent(event_token const&); private: static event<Windows::Foundation::EventHandler<int32_t> > m_myEvent; // MainPage.cpp event_token MainPage::MyEvent(EventHandler<int32_t> const& handler) { return m_myEvent.add(handler); ..

Read more

I conducted the following experiment pch.h #pragma once #include <Unknwn.h> #include <winrt/Windows.Foundation.h> #include <winrt/Windows.Foundation.Collections.h> #include <d3d12.h> #include <dxgi1_4.h> main.cpp #include "pch.h" using namespace winrt; using namespace Windows::Foundation; int main() { init_apartment(); com_ptr<ID3D12Debug> debugController; winrt::check_hresult(D3D12GetDebugInterface(guid_of<ID3D12Debug>(), debugController.put_void())); debugController->EnableDebugLayer(); com_ptr<IDXGIFactory4> dxgiFactory; check_hresult(CreateDXGIFactory1(guid_of<IDXGIFactory4>(), dxgiFactory.put_void())); com_ptr<IDXGIAdapter1> dxgiAdapter{ nullptr }; check_hresult(dxgiFactory->EnumAdapters1(0, dxgiAdapter.put())); com_ptr<ID3D12Device> device; check_hresult(D3D12CreateDevice(dxgiAdapter.get(), D3D_FEATURE_LEVEL_11_0, guid_of<ID3D12Device>(), device.put_void())); com_ptr<ID3D12Device4> device4 = ..

Read more