OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
TDocManager Event Handling

If you specify the dmMenu parameter when you construct your TDocManager object, the document manager handles certain events on behalf of the documents.

It does this by using a response table to process standard menu commands. These menu commands are provided by the document manager even when no documents are opened and regardless of whether you explicitly add the resources to your application. The File menu is also provided by the document manager. These resources are defined in the DOCVIEW.RC file, which is included by DOCVIEW.H. The events that the document manager handles are

  • CM_FILECLOSE
  • CM_FILEOPEN
  • CM_FILENEW
  • CM_FILEREVERT
  • CM_FILESAVE
  • CM_FILESAVEAS
  • CM_VIEWCREATE

In some instances, you might want to handle these events yourself. Because the document manager's event table is the last to be searched, you can handle these events at the view, frame, or application level. Another option is to construct the document manager without the dmMenu parameter. You must then provide functions to handle these events, generally through the application object or your interface object.

You can still call the document manager's functions through the DocManager member of the application object. For example, suppose you want to perform some action before opening a file. Providing the function through your window class TMyWindow might look something like this:

class TMyApp : public TApplication {
public:
TMyApp() : TApplication() {}
void InitMainWindow();
int DocMode;
};
void TMyApp::InitMainWindow() {
SetMainWindow(new TMyWindow());
// Don't specify dmMenu when constructing TDocManager
SetDocManager(new TDocManager(dmMDI));
};
class TMyWindow : public TDecoratedMDIFrame
{
public:
void CmFileOpen();
/*
* You also need to provide the other event handlers
* provided by the document manager.
*/
};
DEFINE_RESPONSE_TABLE1(TMyWindow, TDecoratedMDIFrame)
EV_COMMAND(CM_FILEOPEN, CmFileOpen),
.
.
.
void TMyWindow::CmFileOpen() {
// Do your extra work here.
GetApplication()->GetDocManager()->CmFileOpen();
}
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
#define END_RESPONSE_TABLE
Definition eventhan.h:466
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
Definition eventhan.h:492
#define EV_COMMAND(id, method)
Response table entry for a menu/accelerator/push button message.
Definition windowev.h:171

See Also