A SERVICE OF

logo

Once you’ e got the file name, you can call the document manager’v s
MatchT mplate function to get the proper template for the file type.e
This is done the same way as in Step 11; see page 91.
Once you’ e located a template, call the template’ CreateDocv s
function with the file path as the parameter to the function. This
creates a new document and its corresponding view and opens the,
file into the document.
Once all the files have been opened, call the DragFinish function.
This function releases the memory that Windows allocates during
drag and drop operations.
Here’ how the new EvDropFiles function should look:s
void
TMyApp::EvDropFiles(TDropInfo dropInfo)
{
int fileCount = dropInfo.DragQueryFileCount();
for (int index = 0; index < fileCount; index++) {
int fileLength = dropInfo.DragQueryFileNameLen(index)+1;
char* filePath = new char [fileLength];
dropInfo.DragQueryFile(index, filePath, fileLength);
TDocTemplate* tpl = GetDocManager()->MatchTemplate(filePath);
if (tpl)
tpl->CreateDoc(filePath);
delete filePath;
}
dropInfo.DragFinish();
}
In Step 11, when you wanted to close a view you had to remove the,
Closing a view
view as a client window restore the main window’ menu, and reset, s
the main window’ caption. Y u no longer need to do any of this,s o
because these tasks are handled by the MDI window classes. Here’s
how your EvCloseView function should look:
TMyApp::EvCloseView(TView& /*view*/)
{ // nothing needs to be done here for MDI
}
Y u need to make the following changes in the TDrawDocument ando
Changes to
TDrawView classes. These changes include defining new events,
TDrawDocument
adding new event-handling functions, adding document property
and TDrawView
functions, and more.
98
OWL P ogrammer’ Guider s