2.4. Building a sample application

This section shows you how use eMbedded Visual C++ to produce a simple HelloWorld application.These instructions assume that you are familiar with the eMbedded Visual C++ interface.

  1. Launch eMbedded Visual C++.

  2. Select File → New… from the menus.

  3. Select a WCE MFC AppWizard (exe) project and name it HelloWorld in the New dialog box.

  4. Choose a suitable work directory location for the project and select Win32 (WCE ARMV4I) and Win32 (WCE emulator) as the CPU support. Click OK.

  5. The WCE MFC AppWizard (exe) dialog now appears:

    1. Select Single Document without Document/View architecture support in step 1. Click Next >.

    2. Select Next > again to accept the defaults in step 2.

    3. Choose the Statically linked MFC library option in step 3.

    4. Click Finish to accept the defaults in the rest of the steps.

    5. A review of your chosen options is shown in the next dialog, select OK to create the project.

  6. Now find the OnPaint method of the CChildView class in the ChildView.cpp file.

    Note

    There are several ways of achieving this. See the eMbedded Visual C++ help for more information on using its development interface.

  7. Change the code in the OnPaint function so it resembles the code below:

    void CChildView::OnPaint()
    
    {
    
        CPaintDC dc(this); // device context for painting
    
        CString s = “Hello World”;
    
        CRect rect;
    
        GetClientRect(&rect);
    
        dc.DrawText( s, -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER );
    
    }
    
  8. Select Tools → Options from the menus. Alter the Download options tab so that Always download binary to the target and Always download dependencies to the target are turned OFF.

  9. Compile and build your program using the Build → Build HelloWorld.exe menu option. This builds the WCE emulator version by default.

  10. Select Build → Start Debug → Go from the menus. This starts the emulator and downloads the test application.

  11. You are asked to find commdlg.dll to enable full debugging. Select Cancel.

    Figure 2.2 shows the WCE emulator window when the application is running.

    Figure 2.2. HelloWorld application running on the WCE emulator

    HelloWorld application running on the WCE emulator
  12. In eMbedded Visual C++, select Debug → Stop Debugging. This leaves the WCE emulator running but you can close this as well.

  13. Select Build → Set Active Configuration… and choose HelloWorld - Win32 (WCE ARMV4I) Release from the Set Active Project Configuration dialog list box. Click OK.

  14. Use Build → Build HelloWorld to compile again but this time it is for the target device.

  15. The ARMV4IRel directory in your project directory contains HelloWorld.exe. You can now download this to your target using ActiveSync. See Using ActiveSync to download the sample application for a description of how to do this.

  16. You can start the application on the target and see the same results as the WCE Emulator when it is downloaded.

Copyright © 2004 ARM Limited. All rights reserved.ARM DUI 0272A
Non-Confidential