Export (0) Print
Expand All

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.

NoteNote

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

This walkthrough was written using Visual C++ Development Settings.

To create a multiplatform smart device MFC project

  1. On the File menu, point to New, click Project, expand the Visual C++ node in the Project Types pane, and then click Smart Device.

  2. In the Templates pane, click MFC Smart Device Application.

  3. In the Name box, type HelloMFC.

  4. Click OK to launch the MFC Smart Device Application Wizard.

  5. Click Next to select the platform SDKs to be added to the current project.

  6. From the Installed SDKs pane, select the platforms you want to add to the current project, such as, Smartphone 2003 and Pocket PC 2003.

  7. Click Next to open the Application Type page.

  8. Select the Single Document and Use MFC in a Static Library check boxes. Leave the Document/View architecture support check boxselected.

  9. Click Finish to complete and close the wizard, or click Next to accept the defaults for all the remaining options in the wizard.

NoteNote

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 need to add the following DLLs to the Additional Files property for the configuration of the new platform you added: Mfc80u.dll, Atl80.dll, Msvcr80.dll. This example assumes a retail configuration.

To add code to the OnDraw() method

  1. In Solution Explorer, expand the Source Files node. Double-click HelloMFCView.cpp to open the source file in the editor.

  2. Modify the OnDraw signature to uncomment pDC in the OnDraw(CDC* pDC) method. The resulting line should read:

    void CHelloMFCView::OnDraw(CDC* pDC)
    
  3. 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);
    
  4. 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

  1. On the Tools menu, click Options, click Device Tools, and then click General.

    If Device Tools is not visible, select Show all settings at the bottom of the Options dialog box.

  2. Select the Show device choices before deploying a device project check box.

To deploy the solution

  1. 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.

  2. On the Build menu, click Deploy.

For more information about the code generated for this walkthrough, see Code Explanation: Hello World: A Multiplatform MFC Application for Smart Devices.

Community Additions

ADD
Show:
© 2014 Microsoft