4.2.1 OLE Objects Used in the Viewer

The viewer was developed using the Multiple Document Interface (MDI). MDI is a standard method that allows an application to edit several documents of the same type simultaneously. Each document has its own main window that is enclosed by the main window of the application. Each document window can be minimized or have its size changed independently. The viewer also uses the Doc/View model where the contents of the document are separated from the way the contents are displayed. This makes the display of embedded OLE objects easier. The document controls the storage of the patient record as an OLE compound document. The document is implemented as the C++ class HealthDocument. The display of the data is done by the class HealthView that encapsulates the view. An external data record from the database is inserted using the code in figure 9. All redrawing of the window and other GUI activities are handled by the OWL and OCF library code.

void HealthView::insert_file( const char* fname) {
  static int x = 0;
  static int y = 0;

  // OcView is an object of type TOcView which
  //      manages presentation of compound documents
  // iwFile means take the data from a file; ihLink means linked
  //       rather than embedded
  TOcInitInfo initInfo( ihLink, iwFile, OcView);

  // space out the inserted objects
  TRect rect( 10 + x * 100, 10 + y * 100, (x + 1) * 100, (y + 1)
         * 100);
  if( x == 5) { x = 0; ++y; } 
  else ++x;

  initInfo.HIcon = 0;                     // no icon
  initInfo.Path = (LPOLESTR) fname;       // file where the data is

  // create the new part for the document and make it the currently
  //     selected item
  SetSelection( new TOcPart(*GetOcDoc(), initInfo, rect));

  // tell the view something has been added and redraw the view
  OcView->Rename();
  InvalidatePart(invView);
}

Figure 12. Source Code to link OLE COM Object

Up Previous Next