Simple Client

Before we can discuss the different techniques for using distributed components, we need to create a simple client application, which will be a new project that we’ll name OCRClient. To keep things simple, we’ll use MFC to create a simple dialog application. Follow these directions:

  1. To create a new project, launch the New dialog box by selecting New from the File menu.

  2. Choose the preferred location for the project and type OCRClient in the project edit-box.

  3. Select MFC AppWizard(exe) and click OK to proceed, and you’ll see the MFC AppWizard - Step 1 dialog box.

  4. Choose Dialog based as the type of application, so that the MFC AppWizard will generate the code necessary for a dialog application for you.

  5. Click Finish and the MFC AppWizard will generate the skeleton of a dialog application.

The code generated for this application is straightforward and won’t be explained in this book. In brief, the generated COCRClientApp class models our simple application. When the application starts, it creates a dialog box and displays it until a user dismisses it, at which time the application ends. This dialog is represented by the COCRClientDlg class, which is generated by the MFC AppWizard when you create a dialog application. A dialog application is driven by the single InitInstance function of the generated COCRClientApp class.

BOOL COCRClientApp::InitInstance()
{
   . . .
   COCRClientDlg dlg;
   m_pMainWnd = &dlg;
   int nResponse = dlg.DoModal();
   . . .
}

As you can see from the generated code ...

Get Learning DCOM now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.