home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / VFORM.ZIP / Samples / vfTest / vfTest.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-10  |  8.4 KB  |  315 lines

  1. // -------------------------------------------------------------------------
  2. // Copyright @ 1997 TCK Software, Incorporated
  3. // All Rights Reserved
  4. // -------------------------------------------------------------------------
  5. // vfTest.cpp : Defines the class behaviors for the application.
  6. //
  7.  
  8. #include "stdafx.h"
  9. #include "vfTest.h"
  10.  
  11. #include "MainFrm.h"
  12. #include "ChildFrm.h"
  13. #include "vfTestDoc.h"
  14. #include "vfTestView.h"
  15. #include "PersonView.h"
  16. #include "MorphView.h"
  17. #include "VTreeView.h"
  18. #include "vfPictView.h"
  19.  
  20. #include "Example1Dlg.h"
  21.  
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CVfTestApp
  30.  
  31. BEGIN_MESSAGE_MAP(CVfTestApp, CWinApp)
  32.     //{{AFX_MSG_MAP(CVfTestApp)
  33.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  34.     ON_COMMAND(ID_EXAMPLES_DIALOGEXAMPLE, OnExamplesDialogexample)
  35.     ON_COMMAND(ID_EXAMPLES_TEST, OnExamplesTest)
  36.     ON_COMMAND(ID_EXAMPLES_PERSON, OnExamplesPerson)
  37.     ON_COMMAND(ID_EXAMPLES_MORPH, OnExamplesMorph)
  38.     ON_COMMAND(ID_EXAMPLES_TREE, OnExamplesTree)
  39.     ON_COMMAND(ID_EXAMPLES_PICT, OnExamplesPict)
  40.     //}}AFX_MSG_MAP
  41.     // Standard file based document commands
  42.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  43.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  44.     // Standard print setup command
  45.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  46. END_MESSAGE_MAP()
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CVfTestApp construction
  50.  
  51. CVfTestApp::CVfTestApp()
  52. {
  53.     // TODO: add construction code here,
  54.     // Place all significant initialization in InitInstance
  55. }
  56.  
  57. /////////////////////////////////////////////////////////////////////////////
  58. // The one and only CVfTestApp object
  59.  
  60. CVfTestApp theApp;
  61.  
  62. /////////////////////////////////////////////////////////////////////////////
  63. // CVfTestApp initialization
  64.  
  65. BOOL CVfTestApp::InitInstance()
  66. {
  67.     // Standard initialization
  68.     // If you are not using these features and wish to reduce the size
  69.     //  of your final executable, you should remove from the following
  70.     //  the specific initialization routines you do not need.
  71.  
  72.  
  73.     // Initialize OLE libraries
  74.     if(!AfxOleInit())
  75.     {
  76.         AfxMessageBox(_T("OLE Initialization Failed"));
  77.         return FALSE;
  78.     }
  79.  
  80.     AfxEnableControlContainer();
  81.  
  82. #ifdef _AFXDLL
  83.     Enable3dControls();            // Call this when using MFC in a shared DLL
  84. #else
  85.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  86. #endif
  87.  
  88.     LoadStdProfileSettings();    // Load standard INI file options (including MRU)
  89.  
  90.     VFormRegistrar vfReg;        // Registers the VForm window class
  91.                                 // NOTE: this is automatically done if you
  92.                                 // call VForm::Create
  93.  
  94.     SetRegistryKey(_T("TCK Software"));
  95.  
  96.     // Register the application's document templates.  Document templates
  97.     //  serve as the connection between documents, frame windows and views.
  98.  
  99.     m_pMdtTest = new CMultiDocTemplate(
  100.         IDR_VFTESTTYPE,
  101.         RUNTIME_CLASS(CVfTestDoc),
  102.         RUNTIME_CLASS(CChildFrame),    // custom MDI child frame
  103.         RUNTIME_CLASS(CVfTestView));
  104.     AddDocTemplate(m_pMdtTest);
  105.  
  106.     m_pMdtPerson = new CMultiDocTemplate(
  107.         IDR_DATABASETYPE,
  108.         RUNTIME_CLASS(CVfTestDoc),
  109.         RUNTIME_CLASS(CChildFrame),    // custom MDI child frame
  110.         RUNTIME_CLASS(CPersonView));
  111.     AddDocTemplate(m_pMdtPerson);
  112.  
  113.     m_pMdtMorph = new CMultiDocTemplate(
  114.         IDR_MORPHTYPE,
  115.         RUNTIME_CLASS(CVfTestDoc),
  116.         RUNTIME_CLASS(CChildFrame),    // custom MDI child frame
  117.         RUNTIME_CLASS(CMorphView));
  118.     AddDocTemplate(m_pMdtMorph);
  119.  
  120.     m_pMdtVTree = new CMultiDocTemplate(
  121.         IDR_VTREETYPE,
  122.         RUNTIME_CLASS(CVfTestDoc),
  123.         RUNTIME_CLASS(CChildFrame),    // custom MDI child frame
  124.         RUNTIME_CLASS(CVTreeView));
  125.     AddDocTemplate(m_pMdtVTree);
  126.  
  127.     m_pMdtPicture = new CMultiDocTemplate(
  128.         IDR_PICTTYPE,
  129.         RUNTIME_CLASS(CVfTestDoc),
  130.         RUNTIME_CLASS(CChildFrame),    // custom MDI child frame
  131.         RUNTIME_CLASS(CVfPictView));
  132.     AddDocTemplate(m_pMdtPicture);
  133.  
  134.     // create main MDI Frame window
  135.     CMainFrame* pMainFrame = new CMainFrame;
  136.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  137.         return FALSE;
  138.     m_pMainWnd = pMainFrame;
  139.  
  140.     // Parse command line for standard shell commands, DDE, file open
  141.     CCommandLineInfo cmdInfo;
  142.     ParseCommandLine(cmdInfo);
  143.  
  144.     // Dispatch commands specified on the command line
  145.     // if (!ProcessShellCommand(cmdInfo))
  146.     //     return FALSE;
  147.  
  148.     // The main window has been initialized, so show and update it.
  149.     //pMainFrame->ShowWindow(m_nCmdShow);
  150.     pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
  151.     pMainFrame->UpdateWindow();
  152.  
  153.     OnExamplesPerson();            // Display first window
  154.  
  155.     return TRUE;
  156. }
  157.  
  158. /////////////////////////////////////////////////////////////////////////////
  159. // CAboutDlg dialog used for App About
  160.  
  161. class CAboutDlg : public CDialog
  162. {
  163. public:
  164.     CAboutDlg();
  165.  
  166. // Dialog Data
  167.     //{{AFX_DATA(CAboutDlg)
  168.     enum { IDD = IDD_ABOUTBOX };
  169.     //}}AFX_DATA
  170.  
  171.     // ClassWizard generated virtual function overrides
  172.     //{{AFX_VIRTUAL(CAboutDlg)
  173.     protected:
  174.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  175.     //}}AFX_VIRTUAL
  176.  
  177. // Implementation
  178. protected:
  179.     //{{AFX_MSG(CAboutDlg)
  180.         // No message handlers
  181.     //}}AFX_MSG
  182.     DECLARE_MESSAGE_MAP()
  183. };
  184.  
  185. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  186. {
  187.     //{{AFX_DATA_INIT(CAboutDlg)
  188.     //}}AFX_DATA_INIT
  189. }
  190.  
  191. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  192. {
  193.     CDialog::DoDataExchange(pDX);
  194.     //{{AFX_DATA_MAP(CAboutDlg)
  195.     //}}AFX_DATA_MAP
  196. }
  197.  
  198. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  199.     //{{AFX_MSG_MAP(CAboutDlg)
  200.         // No message handlers
  201.     //}}AFX_MSG_MAP
  202. END_MESSAGE_MAP()
  203.  
  204. // App command to run the dialog
  205. void CVfTestApp::OnAppAbout()
  206. {
  207.     CAboutDlg aboutDlg;
  208.     aboutDlg.DoModal();
  209. }
  210.  
  211. /////////////////////////////////////////////////////////////////////////////
  212. // CVfTestApp commands
  213.  
  214. void CVfTestApp::OnExamplesDialogexample() 
  215. {
  216.     CExample1Dlg dlg;
  217.  
  218.     dlg.DoModal();
  219. }
  220.  
  221. void CVfTestApp::OnExamplesTest() 
  222. {
  223.     CVfTestDoc *pDoc;
  224.  
  225.     POSITION posDoc = m_pMdtTest->GetFirstDocPosition();
  226.     if(posDoc)
  227.     {
  228.         pDoc = (CVfTestDoc*) m_pMdtTest->GetNextDoc(posDoc);
  229.         POSITION posView = pDoc->GetFirstViewPosition();
  230.         CView* pView = (CView*) pDoc->GetNextView(posView);
  231.         pView->GetParentFrame()->ActivateFrame(SW_RESTORE);    // Activate View
  232.         return;
  233.     }
  234.  
  235.     // Make a new window
  236.     pDoc = (CVfTestDoc*) m_pMdtTest->OpenDocumentFile(NULL);
  237.     pDoc->SetTitle(_T("Basic Example"));
  238. }
  239.  
  240. void CVfTestApp::OnExamplesPerson() 
  241. {
  242.     CVfTestDoc *pDoc;
  243.  
  244.     POSITION posDoc = m_pMdtPerson->GetFirstDocPosition();
  245.     if(posDoc)
  246.     {
  247.         pDoc = (CVfTestDoc*) m_pMdtPerson->GetNextDoc(posDoc);
  248.         POSITION posView = pDoc->GetFirstViewPosition();
  249.         CView* pView = (CView*) pDoc->GetNextView(posView);
  250.         pView->GetParentFrame()->ActivateFrame(SW_RESTORE);    // Activate View
  251.         return;
  252.     }
  253.  
  254.     // Make a new window
  255.     pDoc = (CVfTestDoc*) m_pMdtPerson->OpenDocumentFile(NULL);
  256.     pDoc->SetTitle(_T("Person Database Example"));
  257. }
  258.  
  259. void CVfTestApp::OnExamplesMorph() 
  260. {
  261.     CVfTestDoc *pDoc;
  262.  
  263.     POSITION posDoc = m_pMdtMorph->GetFirstDocPosition();
  264.     if(posDoc)
  265.     {
  266.         pDoc = (CVfTestDoc*) m_pMdtMorph->GetNextDoc(posDoc);
  267.         POSITION posView = pDoc->GetFirstViewPosition();
  268.         CView* pView = (CView*) pDoc->GetNextView(posView);
  269.         pView->GetParentFrame()->ActivateFrame(SW_RESTORE);    // Activate View
  270.         return;
  271.     }
  272.  
  273.     // Make a new window
  274.     pDoc = (CVfTestDoc*) m_pMdtMorph->OpenDocumentFile(NULL);
  275.     pDoc->SetTitle(_T("Morphing Example"));
  276. }
  277.  
  278. void CVfTestApp::OnExamplesTree() 
  279. {
  280.     CVfTestDoc *pDoc;
  281.  
  282.     POSITION posDoc = m_pMdtVTree->GetFirstDocPosition();
  283.     if(posDoc)
  284.     {
  285.         pDoc = (CVfTestDoc*) m_pMdtVTree->GetNextDoc(posDoc);
  286.         POSITION posView = pDoc->GetFirstViewPosition();
  287.         CView* pView = (CView*) pDoc->GetNextView(posView);
  288.         pView->GetParentFrame()->ActivateFrame(SW_RESTORE);    // Activate View
  289.         return;
  290.     }
  291.  
  292.     // Make a new window
  293.     pDoc = (CVfTestDoc*) m_pMdtVTree->OpenDocumentFile(NULL);
  294.     pDoc->SetTitle(_T("Tree Example"));
  295. }
  296.  
  297. void CVfTestApp::OnExamplesPict() 
  298. {
  299.     CVfTestDoc *pDoc;
  300.  
  301.     POSITION posDoc = m_pMdtPicture->GetFirstDocPosition();
  302.     if(posDoc)
  303.     {
  304.         pDoc = (CVfTestDoc*) m_pMdtPicture->GetNextDoc(posDoc);
  305.         POSITION posView = pDoc->GetFirstViewPosition();
  306.         CView* pView = (CView*) pDoc->GetNextView(posView);
  307.         pView->GetParentFrame()->ActivateFrame(SW_RESTORE);    // Activate View
  308.         return;
  309.     }
  310.  
  311.     // Make a new window
  312.     pDoc = (CVfTestDoc*) m_pMdtPicture->OpenDocumentFile(NULL);
  313.     pDoc->SetTitle(_T("Picture Controls Example"));
  314. }
  315.