How to Program for Windows Phone 7 in Standard C++ Only

Is it possible to program for Windows Phone 7 in standard C++ only?

EDIT, finally: for WP7 it won't ever be, but for Windows Phone 8 - yes you can. Native apps, C/C++, iOS/Android portability and code sharing, DirectX. You'll need Visual Studio 2012 and Windows 8 for WP8 development, though. VS2010 is not getting the requisite SDK. To run the emulator, you'll need a 64-bit physical Windows 8 box with a SLAT-enabled CPU. You can still develop on a virtual machine, but you'd need a device to run apps, the emulator won't start.

The nongame UI, however, will still be XAML-based and managed. The entirety of Win32 API will not be supported. They're pushing a model with managed UI layer and a native middleware beneath it. Purely native development is still not an option; although one might try with WinMD classes as code-behind for XAML. The visual XAML designer will probably choke, and you'll need a dummy managed DLL anyway.

EDIT: even assembly, as long as it's targeting Thumb-2 and the mnemonics are UAL-style. For running on the simulator, you'd have to produce an alternative set of assembly files (or other sources) targeting Intel.

For the sake of posterity, here's the pre-06/20/2012 answer:


If you work for Microsoft or an OEM, then yes. Otherwise, no (for now).

There's hope though. Google did relent and issued their NDK after a while; Microsoft might, too. The native code capability is already there. Once they come up with a sensible sandboxing solution, why not.

Also, there's already some pressure from big-name software vendors to open up native development. Mozilla people stated outright that there will be no Firefox on WP7 unless it's native. Similar rumors about Flash.

EDIT: if you want a native SDK on WP7, like I do, please go sign the petition here and/or the one over there. Thank you!

EDIT2: see this. It's a leak and therefore not official, but still, I say there's some hope.

EDIT3: also this. Still not official, but this rumor moves the timeframe for native app support even closer - to the upcoming Tango release.

EDIT4: Microsoft seems to be pretty keen to promote WinRT, their new tablet-oriented XAML-based app platform, which allows for (among other things) unmanaged C++. Now, on every other major mobile OS the tablet and the phone app stacks are one and the same. Just sayin'.

EDIT5: there's been some proof-of-concept work along the lines of C++ => LLVM => MSIL and C++ => LLVM => C#, but nothing production-quality so far.

Windows Phone 7 and native C++/CLI

c++/cli can theoretically be used with WPF/Silverlight using the trick of replacing the C# generated from the XAML with a macro definition that can be used inside the main class in a code behind file. I worked out this technique but haven't had the motivation to take it beyond theory - I'm quite happy mixing languages.

As far as using c++/cli in a pure safe mode for your logic code, this may still not be possible but I'd love to hear how someone goes trying it now. Whilst researching it for Silverlight back in 2008 I found this daunting silverlight forum comment:

I just gave Silverlight&C++ it a try by compiling the MSIL from my C++ project into a Silverlight-compatible DLL. The good news: it works, and you can call this code from a Silverlight project. The bad news: The C++ compiler apparently uses MSIL instructions that Silverlight disallows.

So, if you try this, even with the simplest of programs, you'll almost immediately get the exception "Operation could destabilize the runtime." To me, this makes it seem less likely that we'll see Silverlight for C++ soon, as the compiler will need to behave quite a bit differently.

Windows phone 7 native code support

This answer is purely speculative, but I feel that most others who have answered this question miss the point by a long shot. Let's for a moment assume that this is not a vindictive decision by Microsoft, but instead actually a very well thought out engineering decision that has absolutely nothing to do with content restrictions or otherwise. Those issues are just a bonus for MS

Microsoft is entering into the mobile market, this time for real it seems. Pretty soon there will be tens of millions of Nokia phone being shipped using Windows Phone and whatever they get on top of that will just be gravy. Windows Phone though still hasn't really found its home.

In the next year or two, phones, tablets and laptops will finally start converging into a single device. People will carry their phone in their pockets, but that phone will also be the CPU unit of their PC. That means that by simply sitting near a wireless HDMI monitor and connecting a keyboard and mouse via wireless USB (or bluetooth if we're all unlucky), the user will have their entire PC with them at all times. Tablets will become just a battery powered touch screen which interfaces to the PC in your pocket.

So, all software written for Windows Phone should be able to run unmodified on a PC, a tablet and/or a phone. This is because there's a huge chance that the PC you're running will be either x86 or ARM based running Windows 8. When the PC is in your pocket, the user interface you'll see will be the Windows Phone GUI. When you're hooked up to a monitor, you'll see the ribbon interface. But the underlying OS will most likely be Windows 8, not the Windows CE that is currently used.

Based on all this, the only way Microsoft can insure that developers who invest in producing apps for the Windows Mobile market will not be screwed and that users of Windows Mobile devices won't be shorted when the newer platform comes around is to ensure there is a standard system for running apps on all these processors.

Even now, writing for Honeycomb is a nightmare since if you develop native code, you have to support both ARM and x86 and there's no real support mechanism for it. The only solution is to develop, package and ship two versions. Writing apps for iDevices are a little easier since there's no overlap. x86 on desktop, ARM on device. If you have to use native code on device, ARM is all you need. Even then, there is fat binary support on both device and desktop, so this won't be a problem except when optimizing.

In the end, the decision by Microsoft to stick strictly to .NET is probably a good one. Once they have a gazillion Nokia phones on the market and things have settled a bit, native code could be a real possibility.

Windows Phone 7 SDK C or C++

Short answer: you cannot. You have to use C# and XNA.

Long answer:

  • There is no OpenGL API on WP7. You have to use XNA for 3D graphics.

  • You cannot use C++, only managed (.Net) languages. I'm not an expert but I believe officially supported languages are C#, VB.net and F# at the moment. However, you may be able to use other languages as long as you manage to compile those into valid MSIL assembly.

  • Support for non-managed, native languages such as C++ is not coming anytime soon AFAIK.

Windows Phone 7 SDK C or C++

Short answer: you cannot. You have to use C# and XNA.

Long answer:

  • There is no OpenGL API on WP7. You have to use XNA for 3D graphics.

  • You cannot use C++, only managed (.Net) languages. I'm not an expert but I believe officially supported languages are C#, VB.net and F# at the moment. However, you may be able to use other languages as long as you manage to compile those into valid MSIL assembly.

  • Support for non-managed, native languages such as C++ is not coming anytime soon AFAIK.

How do I create an application that works on both the Windows 7 Phone and IPhone?

MonoCross is a Model-View-Controller system that sits on top of MonoTouch, MonoDroid and SilverLight. So letting more of the UI logic be in common.

Is it possible to place hints in Windows Phone 7 TextBoxes?

What you're looking for is normally called a "Watermarked" textbox. It's quite simple to create a control which implements this functionality.

Here are links to a few versions of implementations of this:

  • http://blogs.msdn.com/b/arun/archive/2010/03/29/watermarked-text-box-for-windows-phone.aspx
  • http://www.windowsphonegeek.com/articles/WP7-WatermarkedTextBox-custom-control
  • http://www.danielmoth.com/Blog/Watermark-TextBox-For-Windows-Phone.aspx
  • http://weblogs.asp.net/jdanforth/archive/2010/09/17/silverlight-watermark-textbox-behavior.aspx
  • WatermarkedTextBox for Windows Phone 7?
  • http://www.silverlight-zone.com/2011/03/wp7-watermarkedtextbox-custom-control.html
  • http://watermarktextbox.codeplex.com/

Creating a HTTP request for Windows phone 8 C++/CX

Microsoft's example for IXMLHTTPRequest2, worked for me in windows phone 8 c++/cx

http://msdn.microsoft.com/en-us/library/hh873181.aspx

The only changed I needed to do, was for CreateStreamOverRandomAccessStream which is not implemented in WP8.

Rewrite this method:

void HttpRequest::CreateMemoryStream(IStream **stream)
{
auto randomAccessStream = ref new Windows::Storage::Streams::InMemoryRandomAccessStream();
CheckHResult(CreateStreamOverRandomAccessStream(randomAccessStream, IID_PPV_ARGS(stream)));
}

To this:

void HttpRequest::CreateMemoryStream(IStream** stream)
{
checkHResult(::CreateStreamOnHGlobal(0, TRUE, stream));
}


Related Topics



Leave a reply



Submit