Copyright: Document Registration Component Help


Document Registration Component - Overview

The Document Registration component adds functionality to an AppWizard-generated application to enable opening and printing application documents from within the Explorer and the File Manager. When running under Windows 95, registering documents adds your application to the Document submenu of the Start menu.

Document Registration Component: Specifics


Document Registration Component - Specifics

The Document Registration component makes two modifications to the target application: a code modification and a resource modification.

All code modifications are made in the function InitInstance of the application’s CWinApp-derived class. The following lines of code are appended to the end of the function.

// Enable DDE Execute open

EnableShellOpen();

RegisterShellFileTypes(TRUE);

//You may remove the #ifndef block below if you already have an #ifdef _MAC block around

//the statement m_pMainWnd->DragAcceptFiles(); Just remove the #ifdef _MAC around it.

#ifndef _MAC

m_pMainWnd->DragAcceptFiles();

#endif

As suggested in the code comments, you may remove the ifndef _MAC block at the bottom of the inserted code if your code already contains the following block of code:

#ifdef _MAC

m_pMainWnd->DragAcceptFiles();

#endif _MAC

If your application supports Embedding and Automation, move the line

m_pMainWnd->DragAcceptFiles();

right below the following assignment:

m_pMainWnd = pMainFrame;

Otherwise, DragAcceptFiles will not be called when Embedding/automation is on the command line.

The Document Registration Wizard also modifies your resource file by adding a string “IDR_NEW_APP_STRING”. You will want to rename this string to the ID of the resources used with the document type of your application. For an SDI application, this is typically IDR_MAINFRAME, but for an MDI application, it will be of the type IDR_myAppTYPE, where myApp represents the first six characters of your application name. You can find the correct ID by finding the following assignment to pDocTemplate and using the first parameter to CSingleDocTemplate for an SDI application or CMultiDocTemplate for an MDI application.

In the example below, you would change IDR_NEW_APP_STRING to IDR_MIDOLETYPE after deleting IDR_MIDOLETYPE

pDocTemplate = new CMultiDocTemplate(

IDR_MIDOLETYPE,

RUNTIME_CLASS(CMidoleDoc),

RUNTIME_CLASS(CChildFrame), // custom MDI child frame

RUNTIME_CLASS(CMidoleView));

To delete and change resource strings, follow these steps:

1.	Open your resource file by clicking the Resource View tab.

2.	Expand the Resource node if it is not already expanded.

3.	Expand the String Table node.

4.	Double-click the String Table node to open the string editor.

5.	Find the string named IDR_ MIDOLETYPE and delete it.

6.	Find the string named IDR_NEW_APP_STRING and rename it to IDR_ MIDOLETYPE.

These steps are also written to a docreg.log file if it can be created in your project directory.