c++-cx

Different app behaviour when deployed locally and from Store

时光总嘲笑我的痴心妄想 提交于 2019-12-02 13:39:49
问题 I'm encountering strange issue when app is deployed from Windows Store (beta version). The app is written as Windows Phone 8.1 RunTime. I've a small windows runtime component written in C++/C# which checks for file existence: bool FileEx::FileExists(String^ path) { std::wstring pathW(path->Begin()); std::string myPath(pathW.begin(), pathW.end()); FILE *file = NULL; if (fopen_s(&file, myPath.c_str(), "r") == 0) { fclose(file); return true; } else return false; } TESTING METHOD: Now let's test

custom attached property not found

我只是一个虾纸丫 提交于 2019-12-02 09:59:51
I want to implement a new property (named "MenuForeground") for the pivot element, in order change the color of the PivotItem header through a defined ControlTemplate. Therefore I created a new class for the custom property, added the #include in the needed code-behind xaml.h file and defined a new namespace ("xamlns:cap") according to the namespace of the custom property. PivotProperties.h #pragma once using namespace Windows::UI::Xaml; namespace CustomAttachedProperties { public ref class PivotProperties sealed : Windows::UI::Xaml::DependencyObject { public: static Windows::UI::Color

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

天大地大妈咪最大 提交于 2019-12-02 07:58:40
问题 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:

Different app behaviour when deployed locally and from Store

爱⌒轻易说出口 提交于 2019-12-02 07:01:24
I'm encountering strange issue when app is deployed from Windows Store (beta version). The app is written as Windows Phone 8.1 RunTime. I've a small windows runtime component written in C++/C# which checks for file existence: bool FileEx::FileExists(String^ path) { std::wstring pathW(path->Begin()); std::string myPath(pathW.begin(), pathW.end()); FILE *file = NULL; if (fopen_s(&file, myPath.c_str(), "r") == 0) { fclose(file); return true; } else return false; } TESTING METHOD: Now let's test it with two files - one created in local folder and one in folder in MusicLibrary. Everything is done

Navigate to another page at OnNavigatedTo?

走远了吗. 提交于 2019-12-02 05:27:54
问题 Why does the method Navigate not work when called in the OnNavigatedTo event of this page? Is this behavior reproducible for you? Any ideas how to avoid this problem? void LockScreenPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) { //if user has no PIN protection this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(AnotherPage::typeid)); //else verify PIN } 回答1: To get the right behavior I am now using the dispatcher: this->Dispatcher->RunAsync(Windows::UI:

Changing namespace name of C++ component in Windows Phone causes exception

不羁的心 提交于 2019-12-01 20:56:01
I have a C++ runtime component in a WP8 application, and if I change the namespace name, I get a "TargetInvocation" exception thrown whenever I try to instantiate a class in that namespace. As an example, if I create the default C++ Windows Runtime Component, the header looks like this: #pragma once namespace CppComponent1 { public ref class WindowsPhoneRuntimeComponent sealed { public: WindowsPhoneRuntimeComponent(); }; } If I change CppComponent1 to CppComponent2 in the .h and the .cpp, and then try to instantiate a WindowsPhoneRuntimeComponent object in my C# code, I get the following error

Will Windows 8 Metro support managed c++/cli

与世无争的帅哥 提交于 2019-12-01 19:18:05
I can't seem to find an answer to this question anywhere, but will metro support managed c++ ?? Right now in Visual Studios 2012 RC it does not (in Metro only). I have some frameworks written in c++/cli and wanted to port them to Metro. I know c++/cx is similar, but my c++/cli objects derive from ones written in C# and it would suck to have to rewrite that part of my system (but ok if I do, I just need to know where to go from here). If there are plans to support it when Windows 8 actually comes out, I can wait. Or if not I would like to know now so I can get to work on porting. C++/CLI is not

How to use a custom WinRT library in a Win32 desktop app?

心不动则不痛 提交于 2019-12-01 06:33:50
问题 I have a WinRT class (C++/CX ref class) in my Win32-based desktop app. It accesses WinRT APIs and works just fine. I used this guide to get it working. Now I'm trying to put this class in a library that the desktop app can use. I'm having quite a bit of trouble with this. Here's what I did in Visual Studio 2013: Created a new project by selecting Installed > Templates> Visual C++ > Store Apps > Windows Apps > DLL (Windows) . Added this new DLL project to the solution containing my desktop app

How to get the array of struct with “byte array” from WinRT C++ to C# in Windows Store app?

只愿长相守 提交于 2019-12-01 04:30:25
Here I have a C# metro app with a C++ WinRT component. I need to do something in WinRT, like assign a photo's name/path, and retrieve photo's thumbnail. First, I write a value struct and retrieve struct array function in WinRT C++ as below. public value struct Item { String^ strName; String^ strPath; }; public ref class CTestWinRT sealed { public: CTestWinRT(); void TestOutStructArray(Platform::WriteOnlyArray<Item>^ intOutArray) { intOutArray->Data[0].strName = ref new String(L"test1.jpg"); intOutArray->Data[0].strPath = ref new String(L"c:\\temp"); intOutArray->Data[1].strName = ref new

Is Platform::String really so useless?

柔情痞子 提交于 2019-11-30 18:19:52
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#. The Windows Runtime string type, HSTRING is immutable and is reference counted. The Platform::String type in C++/CX is