'//////////////////////////////////////////////////////////////////////////////////// ' Expert PROJECT ' Expert - (C) Copyright 1993 by Borland International, Inc. All Rights Reserved. ' ' SUBSYSTEM: OWL code template ' FILE: TMDIClient.OWL ' ' ' OVERVIEW ' ======== ' Definition of all OWL classes when can be generated by the CODEGEN phase of ' AppGen and ClassExpert. AppGen generates when all options have been selected ' and multiple classes are generated. ClassExpert uses the CODEGEN phase when ' a new class is generated. '//////////////////////////////////////////////////////////////////////////////////// <<[H]TMDIClient [[TMDIClient]] ##{hheader.snp} #include #pragma hdrstop ##<>[H]TMDIClient ' ' TMDIClient CPP file. ' <<[CPP]TMDIClient [[TMDIClient]] ##{cheader.snp} #include #pragma hdrstop ##@OPT_APPL_DRAGDROP 2 #include ##!@OPT_APPL_DRAGDROP 2 ##: !@OPT_APPL_DOCVIEW #include ##<> Your constructor code here. } [[TMDIClient]]::~[[TMDIClient]] () { Destroy(); // INSERT>> Your destructor code here. } ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE ////////////////////////////////////////////////////////// // [[TMDIClient]] // =========== // MDIClient site initialization. ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE void [[TMDIClient]]::SetupWindow () { // Default SetUpWindow processing. TMDIClient::SetupWindow (); ##--BEGIN-- !@OPT_APPL_DOCVIEW ##<FileData.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; ##OPT_DV_RESET ##OPT_DV_NEXT ##QUERY_DV_DESCR [[Descr]] ##--BEGIN-- QUERY_DV_FILTER [[Filter]] ##(Filter != "*.*") && (Descr != "All Files (*.*)" theApp->FileData.SetFilter("[[Descr]]|[[Filter]]|All Files (*.*)|*.*|"); ##(Filter == "*.*") && (Descr == "All Files (*.*)" theApp->FileData.SetFilter("All Files (*.*)|*.*|"); ##--END-- QUERY_DV_FILTER [[Filter]] ##--END-- !@OPT_APPL_DOCVIEW ##@OPT_APPL_DRAGDROP 2 // Accept files via drag/drop in the client window. DragAcceptFiles(true); } ##--BEGIN-- !@OPT_APPL_DOCVIEW ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE ////////////////////////////////////////////////////////// // [[TMDIClient]] // =========== // Menu File New command ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE void [[TMDIClient]]::CmFileNew () { ##<LoadString(IDS_UNTITLED, title, sizeof(title))) { wsprintf(numberStr, " - %d", ChildCount++); strcat(title, numberStr); } else title[0] = '\0'; ##--END-- BaseClient != "TEditFile" ##--BEGIN-- BaseClient == "TEditFile" char title[255]; ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE // Generate a title for the MDI child window. wsprintf(title, "%d", ChildCount++); ##--END-- BaseClient "TEditFile" ##--BEGIN-- <SetIcon(GetApplication(), IDI_DOC); ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE // If the current active MDI child is maximize then this one should be also. ##<GetWindowLong(GWL_STYLE) & WS_MAXIMIZE)) child->Attr.Style |= WS_MAXIMIZE; child->Create(); } void [[TMDIClient]]::OpenFile (const char *fileName) { ##<FileData.FileName, fileName); // ##<FileData.FileName)); ##BaseClient == "TListBox" 2 [[ClientClass]] far *client = new [[ClientClass]](0, 0, 0, 0, 100, 100); [[TMDIChild]]* child = new [[TMDIChild]](*this, theApp->FileData.FileName, client); ##BaseClient == "TWindow" [[TMDIChild]]* child = new [[TMDIChild]](*this, theApp->FileData.FileName, new [[ClientClass]](0)); ##--END-- TRUE ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE // Associate ICON w/ this child window. child->SetIcon(GetApplication(), IDI_DOC); ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE // If the current active MDI child is maximize then this one should be also. ##<GetWindowLong(GWL_STYLE) & WS_MAXIMIZE)) child->Attr.Style |= WS_MAXIMIZE; child->Create(); LoadTextFile(); } ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE ////////////////////////////////////////////////////////// // [[TMDIClient]] // =========== // Menu File Open command ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE void [[TMDIClient]]::CmFileOpen () { ##<FileData.FileName) = 0; if (TFileOpenDialog(this, theApp->FileData).Execute() == IDOK) OpenFile(); } ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE // Used by ListBox client to read a text file into the list box. void [[TMDIClient]]::LoadTextFile () { char buf[255+1]; ifstream *inStream; ##<GetClientWindow(), TListBox); ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE // Only work if the client class is a TListBox. if (client) { client->ClearList(); inStream = new ifstream(theApp->FileData.FileName); while (inStream->good()) { inStream->getline(buf, sizeof(buf) - 1); if (inStream->good()) client->AddString(buf); } ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE // Return an error message if we had a stream error and it wasn't the eof. if (inStream->bad() && !inStream->eof()) { string msgTemplate(*GetModule(), IDS_UNABLEREAD); char* msg = new char[MAXPATH + msgTemplate.length()]; wsprintf(msg, msgTemplate.c_str(), *(theApp->FileData.FileName)); MessageBox(msg, GetApplication()->GetName(), MB_ICONEXCLAMATION | MB_OK); delete msg; } delete inStream; } } ##--END-- !@OPT_APPL_DOCVIEW ##--BEGIN-- @OPT_APPL_PRINTING ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE ////////////////////////////////////////////////////////// // [[TMDIClient]] // ========== // Menu File Print command ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE void [[TMDIClient]]::CmFilePrint () { ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE // // Create Printer object if not already created. // ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE ##<Printer) theApp->Printer = new TPrinter(GetApplication()); ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE // // Create Printout window and set characteristics. // ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE APXPrintOut printout(theApp->Printer, Title, GetActiveMDIChild()->GetClientWindow(), true); theApp->Printing++; ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE // // Bring up the Print dialog and print the document. // ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE theApp->Printer->Print(GetWindowPtr(GetActiveWindow()), printout, true); theApp->Printing--; } } ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE ////////////////////////////////////////////////////////// // [[TMDIClient]] // ========== // Menu File Print Setup command ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE void [[TMDIClient]]::CmFilePrintSetup () { ##<Printer) theApp->Printer = new TPrinter(GetApplication()); ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE // // Bring up the Print Setup dialog. // ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE theApp->Printer->Setup(this); } } ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE ////////////////////////////////////////////////////////// // [[TMDIClient]] // ========== // Menu File Print Preview command ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE void [[TMDIClient]]::CmFilePrintPreview () { ##<Printer) theApp->Printer = new TPrinter(GetApplication()); theApp->Printing++; PreviewWindow *prevW = new PreviewWindow(Parent, theApp->Printer, GetActiveMDIChild()->GetClientWindow(), "Print Preview", new TLayoutWindow(0)); prevW->Create(); GetApplication()->BeginModal(GetApplication()->GetMainWindow()); ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2 // We must destroy the preview window explicitly. Otherwise, the window will not be destroyed until // it's parent the MainWindow is destroyed. prevW->Destroy(); delete prevW; theApp->Printing--; } } ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE ////////////////////////////////////////////////////////// // [[TMDIClient]] // ========== // Menu enabler used by Print, Print Setup and Print Preview. ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE void [[TMDIClient]]::CmPrintEnable (TCommandEnabler &tce) { if (GetActiveMDIChild()) { ##<Printer) { theApp->Printer = new TPrinter(GetApplication()); tce.Enable(theApp->Printer->GetSetup().Error == 0); } else tce.Enable(theApp->Printer->GetSetup().Error == 0); } } else tce.Enable(false); } ##--END-- @OPT_APPL_PRINTING ##--BEGIN-- @OPT_APPL_DRAGDROP void [[TMDIClient]]::EvDropFiles (TDropInfo) { Parent->ForwardMessage(); } ##--END-- @OPT_APPL_DRAGDROP >>[CPP]TMDIClient