Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » UltraLite - C and C++ Programming » Developing UltraLite Applications for Windows CE » Deploying Windows CE applications

Deploying applications that use ActiveSync Next Page

Assigning class names for applications

When registering applications for use with ActiveSync you must supply a window class name. Assigning class names is carried out at development time and your application development tool documentation is the primary source of information on the topic.

Microsoft Foundation Classes (MFC) dialog boxes are given a generic class name of Dialog, which is shared by all dialogs in the system. This section describes how to assign a distinct class name for your application if you are using MFC and eMbedded Visual C++.

To assign a window class name for MFC applications using eMbedded Visual C++
  1. Create and register a custom window class for dialog boxes, based on the default class.

    Add the following code to your application's startup code. The code must be executed before any dialogs get created:

    WNDCLASS wc;
    if( ! GetClassInfo( NULL, L"Dialog", &wc ) ) {
     AfxMessageBox( L"Error getting class info" );
    wc.lpszClassName = L"MY_APP_CLASS";
    if( ! AfxRegisterClass( &wc ) ) {
     AfxMessageBox( L"Error registering class" );

    where MY_APP_CLASS is the unique class name for your application.

  2. Determine which dialog is the main dialog for your application.

    If your project was created with the MFC Application Wizard, this is likely to be a dialog named CMyAppDlg.

  3. Find and record the resource ID for the main dialog.

    The resource ID is a constant of the same general form as IDD_MYAPP_DIALOG.

  4. Ensure that the main dialog remains open any time your application is running.

    Add the following line to your application's InitInstance function. The line ensures that if the main dialog dlg is closed, the application also closes.

    m_pMainWnd = &dlg;

    For more information, see the Microsoft documentation for CWinThread::m_pMainWnd.

    If the dialog does not remain open for the duration of your application, you must change the window class of other dialogs as well.

  5. Save your changes.

    If eMbedded Visual C++ is open, save your changes and close your project and workspace.

  6. Modify the resource file for your project.

    Locate the resource ID of your main dialog.

  7. Reopen eMbedded Visual C++ and load your project.

  8. Add code to catch the synchronization message.

    See Adding ActiveSync synchronization (MFC).