Thursday, January 05, 2006

Questions about embedding Macromedia Flash in CF application pop up from time to time on the CF NG. In fact it is very easy to do with Flash ActiveX for Pocket PC and WebBrowser control.

Here are five steps to achieve that:

1. Download and install Flash ActiveX for Pocket PC on your Pocket PC.

2. Create Smart Device and CF v2 project in VS 2005 and drop WebBrowser on your form.

3. Add flash file (.SWF) of your choice to your project and set its Built Action to content and “Copy if newer”

4. Create html file and make sure that you have a full path to the .SWF file in the src tag value:

<html>

<head>

<title>Dogshow Gametitle>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

head>

 

<body bgcolor="#FFFFFF" margintop=0 topmargin=0 leftmargin=0 marginleft=0>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="580" height="360">

  <param name=movie value="dogshow.swf">

  <param name=quality value=high>

  <embed src="file://\Program Files\MMediaClient\dogshow.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="580" height="360">

  embed>

 

object>

body>

html>

5. Make a call to the Navigate method with the name of your html file:

webBrowser1.Navigate(new Uri(@“file://\Program Files\MMediaClient\dogshow.htm“));

 

And enjoy the show:

1/5/2006 4:56:57 PM (GMT Standard Time, UTC+00:00)  #     | 
 Tuesday, January 03, 2006

You probably know how difficult it was to create a screen snapshot in CF v1. It required usage of many API calls and custom marshaling of a few structures. Just take a look at these resources:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/scibf.asp?frame=true

http://vault.netcf.tv/VaultService/VaultWeb/Blame.aspx?repid=2&path=%24%2fSDF%2fv1.4%2fOpenNETCF.Drawing%2fGDIPlus.cs&version=5&includedversions=20

The world has become a much better place since release of the CF v2 - availability of the native handles and ability to save image from Bitmap - have reduced the required code to just a few lines and one API call:

private void Snapshot(string filename, Graphics gx, Rectangle rect)

{

     Bitmap bmp = new Bitmap(rect.Width, rect.Height);

     // Create compatible graphics

     Graphics gxComp = Graphics.FromImage(bmp);

     // Blit the image data

     BitBlt(gxComp.GetHdc(), 0, 0, rect.Width, rect.Height, gx.GetHdc(), rect.Left, rect.Top, SRCCOPY);

     bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Bmp);

     // Cleanup

     bmp.Dispose();

     gxComp.Dispose();

}

 

// P/Invoke declaration

[DllImport("coredll.dll")]

public static extern int BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, uint dwRop);

 

const int SRCCOPY = 0x00CC0020;

All you need to use it is just place the Snapshot method on your form and call it like that:

//Create a snapshot of a current view of the TextBox

Snapshot(@"\Temp\save.bmp", this.CreateGraphics(), textBox1.Bounds);

 

1/3/2006 1:44:08 PM (GMT Standard Time, UTC+00:00)  #     | 
 Wednesday, December 21, 2005
 Friday, December 09, 2005

I've got the following info from Microsoft guys that could be helpful for anybody:

The following downloads for SQL Server 2005 Mobile Edition (SQL Server Mobile) available at http://download.microsoft.com is described below. For more information please refer to the SQL Server Mobile website at http://www.microsoft.com/sql/editions/sqlmobile.

a.    Microsoft SQL Server 2005 Mobile Edition Server Tools - The package installs the SQL Server Mobile Replications Components on the machine running the IIS server. The components are required for connecting the SQL Server Mobile database on a mobile device to SQL Server 2000 SP3a database and later versions. Link to download: http://www.microsoft.com/downloads/details.aspx?familyid=6ed0fb7e-7c05-4f59-879a-8fb619e36612&displaylang=en

b.    Microsoft SQL Server 2000 Service Pack 4 Replication Components – The package installs the SQL Server 2000 SP4 replication components on the machine running the IIS server. The components are required for connecting the SQL Mobile database on a mobile device to a SQL Server 2000 SP4 database. Link to download: http://www.microsoft.com/downloads/details.aspx?familyid=a0241f9c-79b1-4011-81e3-2601aa701e02&displaylang=en

c.     Microsoft SQL Server 2000 Service Pack 3a Replication Components – The package installs the SQL Server 2000 SP3a SQL Server 2000 SP3a replication components on the machine running the IIS server. The components are required for connecting the SQL Mobile database on a mobile device to a SQL Server 2000 SP3a database.  Link to download: http://www.microsoft.com/downloads/details.aspx?familyid=a9e0cea0-6f8d-4625-af71-fc8d671f64b6&displaylang=en

d.     Microsoft SQL Server 2005 Mobile Edition Device SDK – The SDK contains the product installers files for installing SQL Server Mobile on the mobile devices, and it also contains the DLL’s and Header files required for developing SQL Mobile applications on the Desktop. Link to download: http://www.microsoft.com/downloads/details.aspx?FamilyId=5BD8ABAA-5813-4DB3-B23A-24551DE2ECC1&displaylang=en

e.     IBuySpy Delivery 2005 Developer Toolkit Sample Application– The Toolkit is a sample e-commerce storefront to demonstrate how simple it is to create scalable applications for the Microsoft® .NET® platform by using SQL Server Mobile . Link to download: http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=7A5F64B0-4E64-4A72-A2C9-994A0C55CECD .

Apart from these the following are also available – 

EULA for SQL Server Mobile Device SDK: http://download.microsoft.com/download/2/4/8/2482E95D-00FD-4374-BD15-57A8C4C34444/EULA.rtf

ReadMe file for SQL Server Mobile Device SDK: http://download.microsoft.com/download/2/4/8/2482E95D-00FD-4374-BD15-57A8C4C34444/SSMREADME.htm

Help File for the SQL Server Mobile: http://download.microsoft.com/download/2/4/8/2482E95D-00FD-4374-BD15-57A8C4C34444/ssm3chm.chm

 

12/9/2005 2:38:47 PM (GMT Standard Time, UTC+00:00)  #     | 
 Friday, October 14, 2005

Watch this demo that shows Avalon err... WPF application executed on the Windows Mobile 5.0 device:

http://channel9.msdn.com/Showpost.aspx?postid=126729

10/14/2005 6:13:35 PM (GMT Daylight Time, UTC+01:00)  #    Comments [31]  | 
 Monday, October 10, 2005

RSS team at Microsoft has posted a link to download the PDC slides from “Windows Vista: Building RSS-enabled applications.”  presentation. In the slides they show the diagram of the RSS objects model and a few code samples of its usage in the managed code. First of all the object structure is presented as a set of interfaces (IFeed, IFeedItem etc..) which is explained by the fact that RSS platform in the Vista are built on COM and the RCW in  .NET exposes COM objects as interfaces. Second of all, because of its COM nature the code in .NET becomes not particularly a .NET friendly forcing a developer to use Class when instantiating an interface instance:

IFeeds feedMgr = new FeedsClass();

foreach (IFeed feed in feedMgr.Subscriptions.Feeds)
{                         
 Console.WriteLine(feed.Name);
 
   foreach (IFeedItem item in feed.Items)
      Console.WriteLine("\t" + item.Title);
 
 Console.WriteLine ();
}

I am not sure why the RSS team has decided use COM for that (probably to make RSS platform accessible from VC++), but it's better than nothing, right?

RSS
10/10/2005 7:08:48 PM (GMT Daylight Time, UTC+01:00)  #    Comments [30]  | 
 Monday, September 26, 2005

I am getting ready for MVP Summit in Seattle (from Wednesday September 28th until Saturday Oct 1th). I am staying in W hotel. Any MVP who wants to meet me, you will find me in the company with the usual suspects :)

On Friday, I received my copy of Framework Design Guidelines : Conventions, Idioms, and Patterns for Reusable .NET Libraries book and I am really enjoying every bit of it. I like Brad's and Krys's “Do, Consider, Avoid, and Do not“ style, but the most interesing I find the inline comments from Paul Vick, Chris Anderson, Brent Rector and others, who reveal many fascinating details on how the whole designing process works at Microsoft and making the text more alive and interactive.

 

9/26/2005 2:23:48 PM (GMT Daylight Time, UTC+01:00)  #    Comments [40]  | 
 Wednesday, September 21, 2005
9/21/2005 9:50:02 PM (GMT Daylight Time, UTC+01:00)  #     |