home *** CD-ROM | disk | FTP | other *** search
- /* Project xped1
-
- Copyright ⌐ 1993. All Rights Reserved.
-
- SUBSYSTEM: xped1.exe Application
- FILE: xped1app.cpp
- AUTHOR:
-
-
- OVERVIEW
- ========
- Source file for implementation of XpEd1App (TApplication).
- */
-
-
- #include <owl\owlpch.h>
- #pragma hdrstop
-
-
- #include "xped1app.h"
- #include "xped1abd.h" // Definition of about dialog.
-
-
- //{{XpEd1App Implementation}}
-
-
- //
- // Build a response table for all messages/commands handled
- // by the application.
- //
- DEFINE_RESPONSE_TABLE1(XpEd1App, TApplication)
- //{{XpEd1AppRSP_TBL_BEGIN}}
- EV_COMMAND(CM_FILENEW, CmFileNew),
- EV_COMMAND(CM_FILEOPEN, CmFileOpen),
- EV_COMMAND(CM_FILECLOSE, CmFileClose),
- EV_COMMAND(CM_HELPABOUT, CmHelpAbout),
- //{{XpEd1AppRSP_TBL_END}}
- END_RESPONSE_TABLE;
-
-
- //
- // FrameWindow must be derived to override Paint for Preview and Print.
- //
- class SDIDecFrame : public TDecoratedFrame {
- public:
- SDIDecFrame (TWindow *parent, const char far *title, TWindow *clientWnd, BOOL trackMenuSelection = FALSE, TModule *module = 0) :
- TDecoratedFrame(parent, title, clientWnd, trackMenuSelection, module)
- { }
- ~SDIDecFrame ()
- { }
- };
-
-
- //////////////////////////////////////////////////////////
- // XpEd1App
- // =====
- //
- XpEd1App::XpEd1App () : TApplication("xped1")
- {
-
- // Common file file flags and filters for Open/Save As dialogs. Filename and directory are
- // computed in the member functions CmFileOpen, and CmFileSaveAs.
- FileData.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
- FileData.SetFilter("All Files (*.*)|*.*|");
-
- // INSERT>> Your constructor code here.
-
- }
-
-
- XpEd1App::~XpEd1App ()
- {
- // INSERT>> Your destructor code here.
-
- }
-
-
- //////////////////////////////////////////////////////////
- // XpEd1App
- // =====
- // Application intialization.
- //
- void XpEd1App::InitMainWindow ()
- {
- Client = new TEditFile(0, 0, 0);
- SDIDecFrame *frame = new SDIDecFrame(0, GetName(), Client, FALSE);
-
- nCmdShow = nCmdShow != SW_SHOWMINIMIZED ? SW_SHOWNORMAL : nCmdShow;
-
- //
- // Assign ICON w/ this application.
- //
- frame->SetIcon(this, IDI_SDIAPPLICATION);
-
- //
- // Menu associated with window and accelerator table associated with table.
- //
- frame->AssignMenu(SDI_MENU);
-
- //
- // Associate with the accelerator table.
- //
- frame->Attr.AccelTable = SDI_MENU;
-
-
- MainWindow = frame;
-
- }
-
-
- //////////////////////////////////////////////////////////
- // XpEd1App
- // ===========
- // Menu File New command
- void XpEd1App::CmFileNew ()
- {
- Client->NewFile();
- }
-
-
- //////////////////////////////////////////////////////////
- // XpEd1App
- // ===========
- // Menu File Open command
- void XpEd1App::CmFileOpen ()
- {
- //
- // Display standard Open dialog box to select a file name.
- //
- *FileData.FileName = 0;
- if (Client->CanClose())
- if (TFileOpenDialog(MainWindow, FileData).Execute() == IDOK)
- OpenFile();
- }
-
-
- void XpEd1App::OpenFile (const char *fileName)
- {
- if (fileName)
- lstrcpy(FileData.FileName, fileName);
-
- Client->ReplaceWith(FileData.FileName);
- }
-
-
- //////////////////////////////////////////////////////////
- // XpEd1App
- // =====
- // Menu File Close command
- void XpEd1App::CmFileClose ()
- {
- if (Client->CanClose())
- Client->DeleteSubText(0, UINT(-1));
- }
-
-
- //////////////////////////////////////////////////////////
- // XpEd1App
- // ===========
- // Menu Help About xped1.exe command
- void XpEd1App::CmHelpAbout ()
- {
- //
- // Show the modal dialog.
- //
- XpEd1AboutDlg(MainWindow).Execute();
- }
-
-
- int OwlMain (int , char* [])
- {
- XpEd1App App;
- int result;
-
- result = App.Run();
-
- return result;
- }
-