This morning I hosted an MSDN webcast on using Visual Studio 2005 to develop C++ applications for Mobile Devices. Let's be kind and say I forgot the launch date of Visual Studio 2005 (doh!) due to nerves, shall we? (It's November 7. Remember, remember the 5th, er, 7th of November as they might say in the UK).
While my blood-pressure starts to return to normal, I thought I would post a transcript of my "script", minus the live demonstration parts. Hopefully those parts weren't too libelous. I'm just relieved the demo worked, as until about an hour before the talk, it wasn't working at all. Those pesky curly-braces caught me out!
You can find out more about webcasts here: http://msdn.microsoft.com/webcasts
Slide 1 - Title
Hello. My name is John Kennedy, I'm a Content Specialist in the Mobile and Embedded Division, and my job is to work with the user assistance team creating documentation for the SDKs.
I'll be using this webchat to talk to you about the new development tools available for the C++ developer wishing to create software for Windows Mobile devices. So I won't be talking about managed C# or VB.
This should be quite interesting, not least because I've never used Live Meeting before, so there's always the potential for lots of things to go wrong.
If there are questions, I may not answer them until towards the end of the chat. And If I don't answer it, I can follow up afterwards - you've probably asked something I don't know the answer to right away.
Let's start off with a quick poll just to wake everyone up.
*** QUICK POLL ***
Slide 2 - What we will cover
As you probably know by now, we've moved away from the Embedded Toolkits (versions 3 and 4) to using Visual Studio as the main development tool . Visual Studio is just a huge powerful monster of a tool, and this gives us many advantages over earlier tools.
However, it can be a bit of a shock, so I'm going to demonstrate some of the important new features, look at some of the cool stuff, and then I'm going to build a simple application for you so you can see it all in action.
Hopefully by the end of this webcast, you'll be excited about using Visual Studio to develop your software using Visual Studio.
Slide 3 - Session Prerequisites
So in order to check out Visual Studio for mobile development yourself, you're going to need a copy of Visual Studio. At this moment, Visual Studio hasn't been released yet, but the good news is that there is a Beta available, and you can download it from the MSDN Developer Center (we'll list the URLs at the end) or even order a copy on DVD for a few dollars.
Visual Studio will include SDKs for Windows 2003 devices, but you should really download and install the Windows Mobile 5.0 SDKs. These are also included on that Evaluation kit DVD.
You'll also need to install a little DMA update patch, and a new version of ActiveSync.
When you are installing Visual Studio, make sure you don't de-select some of the languages you don't think you'll be using, as this can cause some issues with the mobile SDKs.
Slide 4 - Agenda
Here is what I'm going to talk about for the next hour or so.
First, I'll introduce you to Visual Studio. If you haven't used Visual Studio before, don't be afraid. It looks very similar to the Embedded Toolkit, although it has about a billion new features (roughly, I've not actually counted them myself).
I'll then do a very quick little show-and-tell using Visual Studio, and show you some of the cool stuff.
Then we'll put on our serious developer hat, and look at the support for Native Libraries such as ATL and MFC, and finally I'll attempt to build some simple applications using these libraries while you watch and make fun of my typing.
Slide 5 - Visual Studio 2005 - Your new development environment
Well, if you're like me, you really got very fond of the eMbedded Toolkits. They were small, fast, lightweight, and of course, free. Sure there were some issues, and if I saw that retry or switch to another process dialog again, well., I was probably going to give up programming and take up farming, but still, the Embedded Tookkits were good development applications.
What does Visual Studio have to offer?
A lot. Visual Studio is packed with professional development goodness. The IDE itself is a lot more advanced. The Code Editor is improved, with colour coding of key words, outlining (expand/contract sections), and improved intellisense. You can drag panes around and dock them a lot more easily.
The Help system can be configured to go online for content, which is a great way to make sure you always have the latest documentation.
When it comes to native libraries, ATL and MFC have both been updated.
Incidentally, we've not forgotten those developers who want to port older applications for Windows CE 2003, and there is much more information on this topic on the MSDN mobility site.
Slide 6 - Key features
So here are some of my favourite features in Visual Studio 2005, from the perspective of someone writing code in C++ for mobile devices.
First up, you can now develop for multiple devices in the same project. For example, you can create code for Smartphone and Pocket PC, and simply #ifdef out the sections that are platform specific.
You can even develop Desktop and Device applications in the same solution.
And each device can have it's own resource file - very useful if you need to use different graphics or dialogs for different devices.
The emulator. Ah, the emulator. What a fantastic piece of work. In the old days, the emulator for the Pocket PC and Smartphone ran a kind of munged version of the OS and applications, by converting them all the run on the X86 processor.
The new emulator does it the other way round - the emulator actually emulates an ARM processor, and runs exactly the same software as runs on a real device - bit for bit. Obviously this makes the emulator a lot more authentic, and especially if you don't have Windows Mobile 5.0 device to hand, you're going to love it.
The resource editor is improved, with better property editing for example, and dialog templates for different device formats - you know, landscape and portrait.
The Debugger has been thrown out and rebuilt from scratch, so it does all that the embedded toolkit debugger can do, but with all the reliability of the desktop version. You can now attach to process for example. There are several eHowTo videos on using the debugger on the MSDN Mobility site (url at the end) that will demonstrate these features in detail.
And once you've created your application, you can use the Visual Studio set-up projects to quickly create CAB files.
Slide 7 - Demonstration
Ok, enough death-by-powerpoint, it's time to see some of these features in action.
Here is the new project dialog, and you can see that Smart Devices are integrated right in there with the rest of the projects. You'll also find C# and VB.net project types too, as well as the setup and deployment project types.
*** MAKE SURE TO USE WIn32 ****
So here's you create a typical C++ application. I'm going to remove 2003 and add WM5. If you haven't installed the SDKs, you'll see this part is missing.
And here's another new feature: when I build and deploy the application, I don't get an error about predefined headers.
So up pops the emulator, looking very shiny.
Now watch this. I'm going to click on this soft key, and it will rotate the display. You'll notice how my application just rotated properly, and resized itself.
Notice also the new menu style - this is new for Windows mobile 5.0. I really like it, as I think it's a much better UI style for a hand-held device. Of course you can use the existing menu types if you like.
Let's check out a few other things in this emulator.
For example, if I go to File / Configure, I can switch the skin on and off, and change the orientation.
Now one thing which has always been a pain has been getting data into the emulator - you know, graphics files, data files, what have you.
From the emulator properties, I can set up a shared folder. In this case, the folder is simply a folder on my desktop. You can see there's a picture in it.
When I open up the File Explorer, the folder appears as a storage card.
But wait! There's more!
Open up ActiveSync, and set the connections to allow DMA…
Now in Visual Studio go to Tools / Device Emulator Manager, and find the device you have running. It'll have a mark next to it.
Right click and select Cradle.
Notice the ActiveSync spinning.. It's connecting to the emulator!
Now I can go back to Visual Studio and instead of setting my target device to be the emulator, I can set to the connected device. And of course, all the other remote tools work too.
The debugger now allows me to attach to a process, like this:
First, I run the application on the emulator, or the real device, which is stored:
My Device / Program Files / demo1
Then from the Debug menu, I can attach to process.
If you're interested in the debugger, you should watch the eHowTo which goes into a lot more depth. The debugger is very much faster now, and it's a really useful tool when developing.
** Stop debugging, return to source **
If you look at the source code, you can see a lot of #ifdef sections. The new project wizard has added these because we created a project for both Pocket Pc and Smartphone. You can see how you would add your own platform-specific code.
You can also see how there are two sets of resource files added automatically for you.
From the Configuration manager I can add different project types
** Click on Windows Mobile 5.0 Pocket PC **
I can add a Win32 project type here, if I want code to run on the desktop as well. Obviously, this isn't going to work in this situation unless I add a lot more #defs to take the mobile-specific parts into account, but you can see how potentially I can keep a single project and target multiple devices and even the desktop.
Slide 8 - Native Library Support
C++ developers have traditionally made a lot of use of libraries such as MFC and ATL when writing applications. Not for us the easy way out of the .NET Compact Framework - we were using MFC long before managed code came alone 😉
So both MFC and ATL have been updated, and they are much closer in step with their desktop counterparts. Also, for the first time, the Smartphone now supports MFC. ATL and MFC are both available in static and dynamic linked forms. The C runtime is a "mini" C runtime required by ATL and MFC.
A subset of the Standard C++ Library is included, and provides a set of helpful classes for managing data and so on. Who needs C# when you have the Standard Library? Well, at any rate, if you are porting an application, this is will be a big help.
Another option is the Windows Template Library, and although it's not supported by Microsoft, this is a library that you'll like, if you like this kind of library. In other words, if you've used it on the desktop, you'll be pleased to see it is an option at least.
Ok, well the easiest way to see all this is to use it. So now I'm going to attempt to build an ATL ActiveX control.
Slide 9 - Demonstrations
** Don't mess this part up, remember, everyone is watching **