Walkthrough: Creating a Multiplatform MFC Application for Smart Devices
You can use Visual C++ to write code targeting multiple devices. The following walkthrough illustrates how to build a multiplatform MFC application. For more information, see MFC Smart Device Application Wizard.
This walkthrough consists of three main tasks:
Creating a multiplatform smart device MFC project.
Adding code to the multiplatform OnDraw() method.
Deploying the multiplatform solution.
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.
This walkthrough was written using Visual C++ Development Settings.
To create a multiplatform smart device MFC project
On the File menu, point to New, click Project, expand Visual C++ in the Project types pane, and then click Smart Device.
In the Templates pane, click MFC Smart Device Application.
In the Name box, type HelloMFC.
Click OK to start the MFC Smart Device Application Wizard.
Click Next to select the platform SDKs to be added to the current project.
From the Installed SDKs pane, select the platforms you want to add to the current project, such as, Smartphone 2003 and Pocket PC 2003.
Click Next to open the Application Type page.
Select Single document and Use MFC in a static library. Leave the Document/View architecture support check box selected.
Click Finish to complete and close the wizard, or click Next to accept the defaults for all the remaining options in the wizard.
Having created a device project, you can always add more platforms. However, adding a new platform to the project after the initial creation does not add the additional dependent run-time DLLs to the Additional Files configuration property for the added platform. For example, if your application dynamically links to MFC, you will have to add the following DLLs to the Additional Files property for the configuration of the new platform you added: Mfc90u.dll, Atl90.dll, Msvcr90.dll. This example assumes a retail configuration.
To add code to the OnDraw() method
In Solution Explorer, expand Source Files. Double-click HelloMFCView.cpp to open the source file in the editor.
Modify the OnDraw signature to uncomment pDC in the OnDraw(CDC* pDC) method. The resulting line should read:
void CHelloMFCView::OnDraw(CDC* pDC)
Insert the following code after the //TODO comment in the OnDraw method:
// Define a rectangle to draw on the screen. CRect rect; // Use the client area of the MFC form for drawing. GetClientRect(&rect); // Draw the text on the screen. pDC->DrawTextW(_T("Hello World"),11, &rect,1);
On the Build menu, click Rebuild Solution.
To ensure that you are prompted to select a device when you deploy your solution, complete the following procedure.
To prompt for device choices at deployment time
On the Tools menu, click Options, expand Device Tools, and then click General.
If you cannot see Device Tools, select Show all settings at the bottom of the Options dialog box.
Select the Show device choices before deploying a device project check box.
To deploy the solution
On the Target Device drop-down list on the Visual Studio toolbar, select your target, for example, Pocket PC 2003 SE Emulator or Pocket PC 2003 Device.
On the Build menu, click Deploy.
To run the application, run File Explorer on the device or emulator, navigate to \My Device\Program Files\HelloMFC, and tap HelloMFC.exe.
For more information about the code generated for this walkthrough, see Code Explanation: Hello World: A Multiplatform MFC Application for Smart Devices.