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

SAP Sybase SQL Anywhere 16.0 » UltraLite - C and C++ Programming » Application development » UltraLite application development for Windows Mobile


Assigning class names for applications

Assign a distinct class name for your application if you are using MFC. 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 about the topic.


There are no prerequisites for this task.

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

  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 code to your application's InitInstance method.

    m_pMainWnd = &dlg;

    The code ensures that if the dlg main dialog is closed, the application also closes. 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.

  6. Modify the resource file for your project.

    Open your resource file (which has an extension of .rc) in a text editor such as Notepad.

  7. Locate the resource ID of your main dialog.

    Change the main dialog's definition to use the new window class as in the following example. The only change that you should make is the addition of the CLASS line:

    CAPTION "MyApp"
    FONT 8, "System"
           LTEXT   "TODO: Place dialog controls here.",IDC_STATIC,13,33,112,17

    where MY_APP_CLASS is the name of the window class you used earlier.

  8. Save the .rc file.

  9. Add code to catch the synchronization message.


A distinct class name for your application is created.

 See also