home *** CD-ROM | disk | FTP | other *** search
/ C/C++ User's Journal & Wi…eveloper's Journal Tools / C-C__Users_Journal_and_Windows_Developers_Journal_Tools_1997.iso / stingray / gridapp.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-27  |  6.5 KB  |  270 lines

  1. // gridapp.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. // This is a part of the Objective Grid C++ Library.
  5. // Copyright (C) 1995,1996 ClassWorks, Stefan Hoenig.
  6. // All rights reserved.
  7. //
  8. // This source code is only intended as a supplement to
  9. // the Objective Grid Classes Reference and related
  10. // electronic documentation provided with the library.
  11. // See these sources for detailed information regarding
  12. // the Objective Grid product.
  13. //
  14.  
  15. #include "stdafx.h"
  16. #include "gridapp.h"
  17.  
  18. #include "mainfrm.h"
  19. #include "gridsdoc.h"
  20. #include "griddoc2.h"
  21. #include "gridfrms.h"
  22. #include "scrltmdi.h"
  23. #include "browsevw.h"
  24.  
  25. #include "dlgsamp1.h"
  26. #include "dlgsamp2.h"
  27. #include "dlgsamp3.h"
  28. #include "dlgsamp4.h"
  29. #include "dlgsamp5.h"
  30.  
  31. #include "gridsvw.h"
  32. #include "gridsvw2.h"
  33. #include "gridsvw3.h"
  34. #include "gridsvw4.h"
  35. #include "gridsvw5.h"
  36. #include "gridsvw6.h"
  37. #include "gridsvw7.h"
  38. #include "formvw1.h"
  39.  
  40. #ifndef _GXSTATE_H_
  41. #include "gxstate.h"
  42. #endif
  43.  
  44. #include "locale.h"
  45.  
  46. #ifdef _DEBUG
  47. #undef THIS_FILE
  48. static char BASED_CODE THIS_FILE[] = __FILE__;
  49. #endif
  50.  
  51. #define new DEBUG_NEW
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CGridSampleApp
  55.  
  56. BEGIN_MESSAGE_MAP(CGridSampleApp, CWinApp)
  57.     //{{AFX_MSG_MAP(CGridSampleApp)
  58.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  59.     ON_COMMAND(ID_DIALOG_SAMPLE1, OnDialogSample1)
  60.     ON_COMMAND(ID_DIALOG_SAMPLE2, OnDialogSample2)
  61.     ON_COMMAND(ID_DIALOG_SAMPLE3, OnDialogSample3)
  62.     ON_COMMAND(ID_DIALOG_SAMPLE4, OnDialogSample4)
  63.     ON_COMMAND(ID_DIALOG_SAMPLE5, OnDialogSample5)
  64.     //}}AFX_MSG_MAP
  65.     // Standard file based document commands
  66.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  67.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  68.     // Standard print setup command
  69.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  70. END_MESSAGE_MAP()
  71.  
  72. /////////////////////////////////////////////////////////////////////////////
  73. // CGridSampleApp construction
  74.  
  75. CGridSampleApp::CGridSampleApp()
  76. {
  77. }
  78.  
  79. /////////////////////////////////////////////////////////////////////////////
  80. // The one and only CGridSampleApp object
  81.  
  82. CGridSampleApp NEAR theApp;
  83.  
  84. /////////////////////////////////////////////////////////////////////////////
  85. // CGridSampleApp initialization
  86.  
  87. BOOL CGridSampleApp::InitInstance()
  88. {
  89.     /**********************************************************************/
  90.     // Don't forget to call GXInit() as first command in InitInstance!
  91.     // If you have created custom control's with DECLARE/IMPLEMENT_REGISTER,
  92.     // you also have to call the RegisterClass methods of your control.
  93.     /**********************************************************************/
  94.  
  95.     GXInit();       // initializes library and resources
  96.  
  97. #if _MFC_VER >= 0x0400
  98.     AfxOleInit();
  99. #endif
  100.  
  101.     _tsetlocale(LC_ALL, _T(""));
  102.  
  103.     CSample4GridWnd::RegisterClass();
  104.  
  105. #if _MFC_VER >= 0x0300 && !defined(_MAC)
  106.     SetRegistryKey(_T("Stingray"));
  107. #endif
  108.  
  109.     SetDialogBkColor();        // set dialog background color to gray
  110. #if _MFC_VER >= 0x300
  111.     Enable3dControls();
  112. #endif
  113.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  114.  
  115.     // Register the application's document templates.  Document templates
  116.     // serve as the connection between documents, frame windows and views.
  117.  
  118.     // CGridSampleView templates
  119.  
  120.     AddDocTemplate(new CMultiDocTemplate(IDR_GRIDAPTYPE,
  121.             RUNTIME_CLASS(CGridSampleDoc),
  122.             RUNTIME_CLASS(CScrltabsMDIChildWnd),      //
  123.             RUNTIME_CLASS(CGridSampleView)));
  124.  
  125.     AddDocTemplate(new CMultiDocTemplate(IDR_GRIDFWTYPE,
  126.             RUNTIME_CLASS(CSampleDocument2),
  127.             RUNTIME_CLASS(CMDIChildWnd),      //
  128.             RUNTIME_CLASS(CSample1FormView)));
  129.  
  130.     m_pSplitterTemplate = new CMultiDocTemplate(IDR_GRIDAPTYPE,
  131.             RUNTIME_CLASS(CGridSampleDoc),
  132.             RUNTIME_CLASS(CSplitterMDIChildWnd),
  133.             RUNTIME_CLASS(CGridSampleView));
  134.  
  135.     // CDBaseBrowserView templates
  136.  
  137.     AddDocTemplate(m_pDBaseBrowser = new CMultiDocTemplate(IDR_DBFBROWSETYPE,
  138.             RUNTIME_CLASS(CDBaseBrowserDoc),
  139.             RUNTIME_CLASS(CSplitterMDIChildWnd),
  140.             RUNTIME_CLASS(CDBaseBrowserView)));
  141.  
  142.     // create main MDI Frame window
  143.     CMainFrame* pMainFrame = new CMainFrame;
  144.     pMainFrame->m_sSection = _T("Settings");
  145.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  146.         return FALSE;
  147.     pMainFrame->ShowWindow(m_nCmdShow);
  148.     pMainFrame->UpdateWindow();
  149.     m_pMainWnd = pMainFrame;
  150.  
  151.     // enable file manager drag/drop and DDE Execute open
  152.     EnableShellOpen();
  153.     RegisterShellFileTypes();
  154.  
  155.     // simple command line parsing
  156.     if (m_lpCmdLine[0] == _T('\0'))
  157.     {
  158.         // create a new (empty) document
  159.         OnFileNew();
  160.     }
  161.     else if ((m_lpCmdLine[0] == _T('-') || m_lpCmdLine[0] == _T('/')) &&
  162.         (m_lpCmdLine[1] == _T('e') || m_lpCmdLine[1] == _T('E')))
  163.     {
  164.         // program launched embedded - wait for DDE or OLE open
  165.     }
  166.     else
  167.     {
  168.         // open an existing document
  169.         OpenDocumentFile(m_lpCmdLine);
  170.     }
  171.  
  172.     return TRUE;
  173. }
  174.  
  175. BOOL CGridSampleApp::ExitInstance()
  176. {
  177.     delete m_pSplitterTemplate;
  178.  
  179.     GXTerminate();
  180.  
  181.     // Here, you can also call the UnregisterClass methods of your
  182.     // custom controls.
  183.  
  184.     return CWinApp::ExitInstance();
  185. }
  186.  
  187. /////////////////////////////////////////////////////////////////////////////
  188. // CAboutDlg dialog used for App About
  189.  
  190. class CAboutDlg : public CDialog
  191. {
  192. public:
  193.     CAboutDlg();
  194.  
  195. // Dialog Data
  196.     //{{AFX_DATA(CAboutDlg)
  197.     enum { IDD = IDD_ABOUTBOX };
  198.     //}}AFX_DATA
  199.  
  200. // Implementation
  201. protected:
  202.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  203.     //{{AFX_MSG(CAboutDlg)
  204.         // No message handlers
  205.     //}}AFX_MSG
  206.     DECLARE_MESSAGE_MAP()
  207. };
  208.  
  209. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  210. {
  211.     //{{AFX_DATA_INIT(CAboutDlg)
  212.     //}}AFX_DATA_INIT
  213. }
  214.  
  215. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  216. {
  217.     CDialog::DoDataExchange(pDX);
  218.     //{{AFX_DATA_MAP(CAboutDlg)
  219.     //}}AFX_DATA_MAP
  220. }
  221.  
  222. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  223.     //{{AFX_MSG_MAP(CAboutDlg)
  224.         // No message handlers
  225.     //}}AFX_MSG_MAP
  226. END_MESSAGE_MAP()
  227.  
  228. // App command to run the dialog
  229. void CGridSampleApp::OnAppAbout()
  230. {
  231.     CAboutDlg aboutDlg;
  232.     aboutDlg.DoModal();
  233. }
  234.  
  235. /////////////////////////////////////////////////////////////////////////////
  236. // CGridSampleApp commands
  237.  
  238. void CGridSampleApp::OnDialogSample1()
  239. {
  240.     CSample1Dialog dlg;
  241.     dlg.DoModal();
  242. }
  243.  
  244. void CGridSampleApp::OnDialogSample2()
  245. {
  246.     CSample2Dialog dlg;
  247.     dlg.DoModal();
  248. }
  249.  
  250. void CGridSampleApp::OnDialogSample3()
  251. {
  252.     CSample3Dialog dlg;
  253.     dlg.DoModal();
  254. }
  255.  
  256. void CGridSampleApp::OnDialogSample4()
  257. {
  258.     CSample4Dialog dlg;
  259.     dlg.DoModal();
  260. }
  261.  
  262. void CGridSampleApp::OnDialogSample5()
  263. {
  264.     CSample5Dialog dlg;
  265.     dlg.DoModal();
  266. }
  267.  
  268.  
  269.  
  270.