winrt-api | WinRT reference content for developing Microsoft Universal | Runtime Evironment library
kandi X-RAY | winrt-api Summary
kandi X-RAY | winrt-api Summary
WinRT reference content for developing Microsoft Universal Windows Platform (UWP) apps
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of winrt-api
winrt-api Key Features
winrt-api Examples and Code Snippets
Community Discussions
Trending Discussions on winrt-api
QUESTION
I am writing a C++ coroutine for a UWP control using C++/WinRT:
...ANSWER
Answered 2022-Jan-23 at 20:51This seems to be a legacy implementation for MSVSC. MSVSC implemented coroutines before the standard was formally complete, so there are two implementations of async (/async
and /async:strict
). I seem to have the old, non–standard-compliant version turned on.
The standard is clear that you cannot use plain return
statements in coroutines (emphasis added):
Coroutines cannot use variadic arguments, plain return statements, or placeholder return types (auto or Concept). Constexpr functions, constructors, destructors, and the main function cannot be coroutines.
— https://en.cppreference.com/w/cpp/language/coroutines
You can verify that this is a legacy behavior with a simple example (view in Godbolt):
QUESTION
I am following the BookStore data binding example, documented at XAML controls; bind to a C++/WinRT property, up to and including the "Bind the button to the Title property" section.
My starting point is a new "Blank App, Packaged (WinUI 3 in Desktop)" project in Visual Studio.
[EDIT] Starting from a "Blank App (C++/WinRT)" project, which is for UWP apps, works perfectly. The problem persists with "WinUI 3 in Desktop" projects.
The initial data binding works and the button content L"Atticus"
is read from the BookSku title property. However calling MainViewModel().BookSku().Title(L"To Kill a Mockingbird");
in the click handler, as directed in article, throws the exception
Exception thrown at 0x00007FFC801B4ED9 (KernelBase.dll) in BookStore.exe: WinRT originate error - 0x8001010E : 'The application called an interface that was marshalled for a different thread.'.
Stepping through the code, the call
m_propertyChanged(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"Title" });
in void BookSku::Title(hstring const& value)
is where the exception is thrown from within.
I can change the button content manually, not through the binding property.
The first example in the Data binding in depth article describes a very similar, though slightly less complicated, data binding scenario. It throws the same exception.
I am using latest Microsoft.Windows.CppWinRT version 2.0.210825.3 and Windows App SDK version 0.8.3
...ANSWER
Answered 2021-Sep-09 at 02:42The application called an interface that was marshalled for a different thread
The problem is you update the property in the no-uithread, so it will throw the above exception, you could use the following to go back to ui-thread before updating the property.
QUESTION
I would like to allow the user to connect to paired audio devices directly from the app instead of navigating to the bluetooth settings manually.
I am successfully listing all bluetooth devices using WinRT Apis:
...ANSWER
Answered 2021-Jul-27 at 19:35Why would you ever expect that the following line would work:
private const string bluetoothDll = "bthprops.cpl";
when MSDN's page states:
DLL: Bthprops.dll
?
QUESTION
I would like to use OpenSSL-1.1.1g in a C++/WinRT project. So i created a test project. The below is what did i do in this project:
1.Install C++/WinRT in VS2019
2.Create project "TestOpenSSL1.1.1g" in the directory "c:\temp" (File->New->Project->Blank App(C++/WinRT))
3.Install Strawberry Perl and NASM
4.Download OpenSSL-1.1.1g and extract it to "c:\temp\openssl-1.1.1g"
5.Open "Developer Command Prompt for VS 2019" with "Run as Administrator"
6.Enter the directory "openssl-1.1.1g"
cd c:\temp\openssl-1.1.1g
7.Configure openssl
perl configure VC-WIN32 --prefix="c:\temp\TestOpenSSL1.1.1g\openssl-1.1.1g"
8.Compile openssl
nmake
9.Install openssl
nmake install
10.So i saw the directories "bin" "html" "include" "lib" were created in "c:\temp\TestOpenSSL1.1.1g\openssl-1.1.1g"
11.Include openssl header files
Add "$(ProjectDir)..\openssl-1.1.1g\include" in Solution Explorer->Properties->Configuration properties->C/C++ ->General->Additional include directories
12.Add dependencies "libcrypto.lib" and "libssl.lib"
Add "$(ProjectDir)..\openssl-1.1.1g\lib\libcrypto.lib;$(ProjectDir)..\openssl-1.1.1g\lib\libssl.lib" in Solution Explorer->Properties->Configuration properties->Linker->Input->Additional dependencies
13.Modify MainPage.cpp
#include
Add statement "OPENSSL_init();" in function "MainPage::MainPage";
After all these I built this project, there was no error. but if i debug this project the errors came:
...ANSWER
Answered 2020-Sep-23 at 06:53It works after using the source codes from openssl and configuring with command "perl Configure VC-WIN32-UWP"
QUESTION
This error happens to me when I use the helper function from microsoft docs to migrate to winrt from cx. I see a similar question here, but the solution mentioned doesn't seem to work for me. The solution mentioned here add #include before any other winrt headers in the file which has this error.
...ANSWER
Answered 2020-Aug-13 at 14:20winrt::guid_of()
returns a winrt::guid
. Per What's new in C++/WinRT:
- Breaking change. GUID is now projected as
winrt::guid
. For APIs that you implement, you must usewinrt::guid
for GUID parameters. Otherwise,winrt::guid
converts to GUID, as long as you include unknwn.h before you include any C++/WinRT headers. See Interoperating with the ABI's GUID struct.
Per Interoperating with the ABI's GUID struct:
GUID
is projected aswinrt::guid
. For APIs that you implement, you must usewinrt::guid
forGUID
parameters. Otherwise, there are automatic conversions betweenwinrt::guid
andGUID
as long as you includeunknwn.h
(implicitly included by and many other header files) before you include any C++/WinRT headers.If you don't do that, then you can hard-
reinterpret_cast
between them.
So, either make sure unknwn.h
is included before WinRT headers, or else you can reinterpret_cast
explicitly, eg:
QUESTION
File.h:
...ANSWER
Answered 2020-Aug-04 at 22:26std::map::find returns an iterator. An iterator doesn't have first
or second
members, unlike the actual items of the map. If you want to access the item, you need to dereference the iterator, either by using the *
or the ->
operators:
QUESTION
I am porting my project from C++/CX to C++/WinRT. For this I need to do some interop stuff like this: https://docs.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/interop-winrt-cx.
Microsoft recommends using helper functions like these for interoperability.
...from_cx and to_cx functions The helper function below converts a C++/CX object to an equivalent C++/WinRT object. The function casts a C++/CX object to its underlying IUnknown interface pointer. It then calls QueryInterface on that pointer to query for the default interface of the C++/WinRT object. QueryInterface is the Windows Runtime application binary interface (ABI) equivalent of the C++/CX safe_cast extension. And, the winrt::put_abi function retrieves the address of a C++/WinRT object's underlying IUnknown interface pointer so that it can be set to another value.
ANSWER
Answered 2020-Aug-10 at 09:12Converting a winrt::UI::Xaml::Controls::TextBlock object to C++/CX object
If you want to port a C++/WinRT object to a C++/CX object. You could make Windows Runtime Component(C++/WinRT) project for the solution and put the converting code in it. Then make the C++/WinRT project refer the above Component (Right click the C++/WinRT project name int the Solution Explorer, click Add, choose References, select the component name you just added under Projects in the Add Reference dialog).
Note
You need to use Consume Windows Runtime Extension>Yes(/ZM) in the Windows Runtime Component(C++/WinRT) project instead of the C++/WinRT project.
Then, in the Windows Runtime Component(C++/WinRT), add cx namespace and winrt namespace to distinct the different object using different language.
The following code can be put into your component project’s class.
Add the needed headers such as:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install winrt-api
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page