c++-cx

Using IMFSourceReader to open a video file

≡放荡痞女 提交于 2019-12-11 07:56:30
问题 I want to open a video file using IMFSourceReader to access its Frames as IMFSample. In a WinRT C++ Class I send the RandomAccessStream of a video file and use the following code to create an IMFSourceReader object. HRESULT hr = S_OK; ComPtr<IMFSourceReader> pSourceReader; ComPtr<IMFByteStream> spByteStream; if (SUCCEEDED(hr)) { // Initialize the Media Foundation platform. hr = MFStartup(MF_VERSION); hr = MFCreateMFByteStreamOnStreamEx((IUnknown*)InputVideoStream, &spByteStream); ComPtr

Thread safety of the reference count of a C++/CX WinRT pointer

房东的猫 提交于 2019-12-11 06:21:15
问题 I was under the impression that the reference count to WinRT objects was thread safe, given the use case. But I've run into a bug that I don't know any other way to explain. For example, the following code crashes quite quickly: ref class C sealed { public: C() { } virtual ~C() {} }; [Windows::Foundation::Metadata::WebHostHidden] public ref class MainPage sealed { public: MainPage() : _latest(nullptr) { InitializeComponent(); Windows::System::Threading::ThreadPool::RunAsync( ref new Windows:

How do I call the base class implementation TextBox::OnKeyDown() in my override?

痞子三分冷 提交于 2019-12-11 05:14:48
问题 I have created a subclass of the TextBox class so that I can capture all keyboard events in the OnKeyDown() method ( the KeyDown event will not trigger for all keyboard events, including but not limited to, backspace and arrow-keys, but OnKeyDown will) . The problem with this is that it effectively disables the TextBox, as it bypasses the control's internal keyboard handling entirely. The obvious solution is to call OnKeyDown in the superclass. How do I do that in Windows Runtime? Just

Hard-coded PCH name in WinRT XAML

孤人 提交于 2019-12-11 04:55:48
问题 WinRT project, C++/CX. When my XAML files are compiled, the generated code files contain an #include "pch.h" line. I want my precompiler header to be called differently - stdafx.h , for legacy code reasons. Changing it in project properties affects C++ sources, but not the XAML compiler - it still emits the pch.h line. I could not find XAML compiler settings anywhere in the project properties. How do I change the PCH name that XAML compiler assumes, please? 回答1: The name of the precompiled

How may I create a C++(/CX ?) _DESKTOP_ Windows 8 application using XAML for GUI?

左心房为你撑大大i 提交于 2019-12-11 01:37:17
问题 how may I create a C++ (maybe requiring /CX extension) desktop Windows 8 application using XAML (and its visual editor) for the GUI? To be explicit NOT creating a Windows store application, I mean, something similar to using plain C++ and Qt (with Designer). 回答1: Windows Desktop and Windows App Store are essentially incompatible target environments. There is no desktop XAML (i.e. WPF) project type for C++. Your options are: use WinForms to create a C++/CLI desktop app with a designer use MFC

how to access namespace “windows”

眉间皱痕 提交于 2019-12-10 21:57:08
问题 #include<iostream> #include<string.h> #include<Windows.h> . . . using namespace Windows::Networking::Connectivity; . . . ConnectionProfile^ internetConnectionProfile = NetworkInformation::GetInternetConnectionProfile(); . . . The above is the code but it is showing error C2653: 'Windows' : is not a class or namespace name What do I do? Common Language Runtime Support(/clr) is set 回答1: I think you want to use C++/CX (not C++/CLI). The languages are practically identical (in terms of how their

Parallel Programming stuck on 4th instance of Concurrency::create_task call for serial devices

喜欢而已 提交于 2019-12-10 20:06:31
问题 I am currently developing a program where Raspberry Pi 3 will read contents sent by 4 Arduino (USB) devices through serial communication every 100ms. The UI gets stuck on the fourth call (serialDeviceIndex = 3) of Concurrency::create_task but if there are only 3 Arduino devices, the problem is not happening and the thread execution continues to the .then lambda body. Can you help me pin point what is the problem? Here's the function called when the connect button from the xaml devices is

C++ equivalent of .NET's Task.Delay?

醉酒当歌 提交于 2019-12-10 13:54:42
问题 I'm writing a C++/CX component to be consumed by Window's store Apps. I'm looking for a way to accomplish what Task.Delay(1000) does in C#. 回答1: Old Question, but still unanswered. You can use #include <chrono> #include <thread> std::this_thread::sleep_for(std::chrono::milliseconds(1000)); This will need C++11, which shouldn't be a problem when using C++/CX. 回答2: I'm not going to claim to be a wizard - I'm still fairly new to UWP and C++/CX., but what I'm using is the following: public ref

Why is [Windows::Foundation::Metadata::WebHostHidden] added by default in custom WinRT C++/CX controls?

江枫思渺然 提交于 2019-12-08 17:35:52
问题 When I create a new control in a WinRT C++/CX project, the class attribute [Windows::Foundation::Metadata::WebHostHidden] is added by default by Visual Studio 2012. Example: namespace WindowsRuntimeComponent1 { [Windows::Foundation::Metadata::WebHostHidden] public ref class MyUserControl sealed { public: MyUserControl(); }; } Is there any documented reason for this? (I did my homework but I failed to find this piece of information) As far as I know, using the attribute [WebHostHidden] makes

ListView Windows 8 multiple indexes

会有一股神秘感。 提交于 2019-12-08 08:30:30
问题 When you have a ListView in Windows 8 Metro Style Apps how can you get all the indexes selected supposing you have multiple selection enabled? void itemsChanged (Platform::Object^ sender, Windows::UI::Xaml::Controls::Controls::SelectionChangedEventArgs^ e { // get selected indexes } 回答1: You would have to compare the SelectedItems property of the sender (the ListView) with the Items property. It appears that SelectedItems add to the collection and remove from the collection in the order items