c++-cx

Is Platform::String really so useless?

不想你离开。 提交于 2019-11-30 16:49:40
问题 I am trying to write a few lines of code in C++/CX in a "Windows Store" (aka Metro Style) application, and I am surprised to see that Platform::String is missing many basic string operations like "replace" or "index of". I suppose I could use the internal data, pass it to a std:string instance and apply the operations I need, but I would like to know if I am missing some "Platform::* only" way of doing these operations. Please note this question is about C++/CX, not C#. 回答1: The Windows

Calling C# method from C++ code in WP8

自闭症网瘾萝莉.ら 提交于 2019-11-30 12:45:06
问题 I'm interested in calling a C# method from C++ code in Windows Phone 8. I have already learned how to pass a callback function to C++ code from C# via delegate declarations in my C++ code, but I am looking to see if I can do any of the following: Call certain methods directly from the C++ code. This would involve somehow inspecting the C# object makeup from C++, and seems unlikely to me, but I thought I'd ask you all anyway Trigger events in the C# code, which can then be handled by C#

Can C++/CX and C++/WinRT be used in the same project?

浪尽此生 提交于 2019-11-30 12:30:54
Earlier this week, Kenny Kerr presented C++/WinRT at CppCon 2016 1 . It is a Standard C++ projection for the Windows Runtime, based on Modern . As far as I understand, the C++/CX compiler/preprocessor/code generator doesn't touch Standard C++ code, and with C++/WinRT being a Standard C++ library it is my naïve interpretation, that both C++/CX and C++/WinRT can be used in the same project. Questions: First things first: Is my naïve interpretation correct? If so, can C++/CX and C++/WinRT be used in the same compilation unit? At what granularity can C++/CX and C++/WinRT be mixed, in case they

What is _In_ in C++?

ぐ巨炮叔叔 提交于 2019-11-30 05:55:32
I have searched this up rather a lot, but come up with no helpful results. I am currently trying to program simple DirextX game for Windows 8 Metro, and have come across _In_ rather a lot. I'm just wondering what it is. Also, I have seen a lot of the use of ^ as the pointer * which I found odd. On top of this, some classes have an interface of ref class MyClass , which I believe is for C# legibility. Anyway, any help would be brilliant. James McNellis It is a SAL annotation , used for code analysis. The annotations themselves are defined as macros that, in normal builds, expand to nothing. The

Calling C# method from C++ code in WP8

倖福魔咒の 提交于 2019-11-30 03:40:27
I'm interested in calling a C# method from C++ code in Windows Phone 8. I have already learned how to pass a callback function to C++ code from C# via delegate declarations in my C++ code, but I am looking to see if I can do any of the following: Call certain methods directly from the C++ code. This would involve somehow inspecting the C# object makeup from C++, and seems unlikely to me, but I thought I'd ask you all anyway Trigger events in the C# code, which can then be handled by C# methods Use a dispatcher to call C# callbacks in the Main UI thread so that the callbacks can modify UI

How can I serialize thread execution across a task continuation block?

狂风中的少年 提交于 2019-11-29 18:08:38
In the below example, a call to HandleChangesAsync is made from within an asynchronous task, and via an event handler. Question - Is there a way to ensure that only one thread can execute the HandleChangesAsync create_task + task continuation blocks at a time (even if the task continuation blocks invoke other async functions)? Note that I can't just use a synchronization primitive because HandleChangesAsync can return before the async operations complete. void MyClass::DoStuffAsync() { WeakReference weakThis(this); create_task(DoMoreStuffAsync()) .then([weakThis]()) { auto strongThis =

How can I serialize thread execution across a task continuation block?

三世轮回 提交于 2019-11-28 12:50:42
问题 In the below example, a call to HandleChangesAsync is made from within an asynchronous task, and via an event handler. Question - Is there a way to ensure that only one thread can execute the HandleChangesAsync create_task + task continuation blocks at a time (even if the task continuation blocks invoke other async functions)? Note that I can't just use a synchronization primitive because HandleChangesAsync can return before the async operations complete. void MyClass::DoStuffAsync() {

Listview selection display with no padding and no checkmark

时光毁灭记忆、已成空白 提交于 2019-11-28 08:47:41
I have this XAML to display a ListView in a C++/CX code. The ListView will be used as a selection menu. <ListView x:Name="itemsListView" ItemsSource="{Binding Source={StaticResource MenuDataSourceCVS}}" HorizontalAlignment="Stretch" Width="230" Margin="0,45,0,0" VerticalAlignment="Top" Grid.Row="1" SelectionChanged="itemsListView_SelectionChanged" SelectionMode="Single" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" FontFamily="Global User Interface"> <ListView.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Height="40" Width="230"> <TextBlock Text="

Copying assets into UWP application package

时光总嘲笑我的痴心妄想 提交于 2019-11-28 04:34:13
问题 I have a large folder structure with a ton of subfolders that I am using for application data in my UWP app. When testing, I can just have it sitting on disk and it's fine, but when I make a store package, I need to be able to copy that data in. The only way I've found to include assets is to manually add individual files into Visual Studio and set them to be "Content". Is there a way to copy in an entire folder as "Content" and preserve its folder structure? 回答1: You don't have to manually

How to convert Platform::String to char*?

大兔子大兔子 提交于 2019-11-27 09:25:18
How do I convert the contents of a Platform::String to be used by functions that expect a char* based string? I'm assuming WinRT provides helper functions for this but I just can't find them. Thanks! Platform::String::Data() will return a wchar_t const* pointing to the contents of the string (similar to std::wstring::c_str() ). Platform::String represents an immutable string, so there's no accessor to get a wchar_t* . You'll need to copy its contents, e.g. into a std::wstring , to make changes. There's no direct way to get a char* or a char const* because Platform::String uses wide characters