Freigeben über


Windows Mobile 6.5 – Part VII: Hello World Widget

How often do you get to pick a Blank Solution at the start of a tutorial? :)

image

Add a new HTML file: this will be for the markup that describes what your widget looks like.

image

Add a new XML file named config.xml: this will be the manifest – the description of what the widget framework should do with the files in the widget package.

image

I borrowed the “next menu” arrow icon from Windows DVD Maker which is a PNG file just like we need (found in C:\Program Files\DVD Maker\Shared\DvdStyles\Sports).

image 

Remember: go back to the config.xml and change the Icon Element:

   <icon src="NextMenuButtonIcon.png"/>

Now we need to ZIP the folder that contains our files. Since I have already forgotten where it was saved, I used this feature:

image

OOPS: NO ICON!

I dragged the PNG file from Windows Explorer into Visual Studio’s Solution Explorer, but the drag & drop didn’t copy the file.

OK: manual action: go copy that PNG file into your solution folder. You should have four files:

image

We don’t need the solution file, but we’ll ignore it for now.

As per the instructions, packaged widgets are just ZIP files, so create a ZIP of the files in your solution folder:

image

DO NOT DO THIS:

image

NOTE 0: The files must be in the root of the ZIP file. If you select the folder and use “Send to… Compressed folder” they end up in a subfolder inside the ZIP.

NOTE 1: From what I’ve read, the name of the ZIP file only matters if you don’t specify the name in the config.xml file. I like things neat…

NOTE 2: The extension of the file should be .ZIP, but to make it a widget, rename the file to have the extension .wgt.

NOTE 3: In the default configuration of Windows 7, the file extension is hidden for known file types (extensions with program mappings).

Remove the check mark from “Hide extensions for known file types” in the dialog found under Tools | Folder Options in Windows Explorer:

image 

Now at this point, Windows no longer knows the file type, but Windows Mobile 6.5 does: copy the WGT file into the emulated mobile device’s My Documents folder:

image

In the emulator, open the start menu, File Explorer

imageimage

I had to use the keyboard to scroll down:

image image

If you zipped the whole folder instead of just the files, you will get this error: “Sorry, this Widget is not compatible with this device”.

image

If all went well, you should see this:

image

In the config.xml file we requested internet access, but the user has control:

image

And then we see Hello Widget World:

image

After you exit you can again find it on the Start menu:

image

Congratulations, you are on the road to Widget Wealth! :)

Special thanks to Jorge Peraza for politely pointing out the ZIP’d files vs. folder issue – yes, I made that mistake even though he tells us clearly on his blog entry.