Using C++/CX in Desktop apps

September 29, 2012

In my first and second post on using WinRT in a desktop app, we’ve used the raw API and then WRL to create and access WinRT objects. It would be easier to access WinRT using the new C++/CX extensions. Can we do that from a desktop app? Let’s give it a try.We’ll start with a regular Win32 Console application project. The first thing we need to do is to enable the C++/CX extensions. Open project properties and navigate to the C/C++ / General node and set “Consume Windows Runtime Extension” to Yes:Building the project now causes the compiler to...

My WPF book has been published

September 28, 2012

My book, WPF 4.5 Cookbook has just been published by Packt Publishing. As an added bonus, Packt publishing is celebrating its 1000th title, and all those with registered accounts at Packt, and those who register by the 30th (2 days to go), will be able to select a free e-book from all published books. If that not enough, Packt provides a free 7-day access to its PacktLib book library.Go over to this link and log in or create an account, and claim your free e-book!
tags: ,
no comments

Accessing WinRT from Desktop Apps (Part 2)

September 24, 2012

In the previous post we’ve seen how to instantiate WinRT objects using the raw (Ro, pun intended) API. In this post, we’ll see some shortcuts to make our lives a little easier.These shortcuts are part of the Windows Runtime template Library (WRL). This is a helper library, similar in spirit to the Active Template Library (ATL) used for classic COM work.First we need to include the main WRL header, <wrl.h>. Also, we’ll include another header with some extra helpers, that are not included with the primary header:#include <wrl.h> #include <wrl/wrappers/corewrappers.h> Next, we’ll add using namespace statements to make our lives a...
no comments

Accessing WinRT From Desktop apps (Part 1)

September 13, 2012

The Windows Runtime (WinRT) is the underlying runtime for Windows 8 Store Apps (“Metro”), but some of it can be actually used outside the Metro environment, in regular desktop apps, such as pure Win32, MFC, etc.There are several ways to go about it; most of the time we’ll use the Windows Runtime Library (WRL) to help out with some of the low level details. Or, for a true high level abstraction, we can use the C++/CX extensions to the C++ language (making our code non-standard). But, just for kicks, let’s see how we can access WinRT types with no...

Windows Phone 8 is soon upon us (and MS Israel hands out 7.5 phones)

September 9, 2012

(this is not my typical technical post, but it’s nice to have something different for a change)A few days ago Microsoft and Nokia held a press conference in New York, in which Nokia presented two new phone devices running Windows Phone 8: The Lumia 820 and the Lumia 920. This announcement made a short while after Samsung announced its first WP8 device, the ATIV S.You can watch the press conference video here. The 920 sure looks impressive in style and functionality.Windows Phone 8 is expected to be publicly available on October 29th (according to rumors…), a few days after...
no comments

Windows Phone: Playing Sound Effects

September 3, 2012

I wanted to create a simple timer application for Windows Phone. The timer would count backwards from a user configured value and when it reached zero, it would play some sound effect to indicate expiration. Sounds simple enough…This is how the application looks like:The problem turned out to be playing that sound effect. I had a WAV file I wanted to play. Silverlight has a MediaElement object that is capable of playing video and/or audio, so it seemed to be a good candidate for the job. MediaElement is an element, so must be placed somewhere in the visual tree....
no comments