home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / ole_vbx1 / testvbx.cpp < prev    next >
C/C++ Source or Header  |  1994-02-17  |  5KB  |  174 lines

  1. // testvbx.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "testvbx.h"
  6.  
  7. #include "mainfrm.h"
  8. #include "testvdoc.h"
  9. #include "testvvw.h"
  10.  
  11. #ifdef _DEBUG
  12. #undef THIS_FILE
  13. static char BASED_CODE THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. LPCSTR lpszVBXFileName = "OL_VBX.VBX";
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CTestvbxApp
  20.  
  21. BEGIN_MESSAGE_MAP(CTestvbxApp, CWinApp)
  22.     //{{AFX_MSG_MAP(CTestvbxApp)
  23.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  24.         // NOTE - the ClassWizard will add and remove mapping macros here.
  25.         //    DO NOT EDIT what you see in these blocks of generated code!
  26.     //}}AFX_MSG_MAP
  27.     // Standard file based document commands
  28.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  29.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  30. END_MESSAGE_MAP()
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CTestvbxApp construction
  34.  
  35. CTestvbxApp::CTestvbxApp()
  36. {
  37.     // TODO: add construction code here,
  38.     // Place all significant initialization in InitInstance
  39. }
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // The one and only CTestvbxApp object
  43.  
  44. CTestvbxApp NEAR theApp;
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CTestvbxApp initialization
  48.  
  49. BOOL CTestvbxApp::InitInstance()
  50. {
  51.     // Standard initialization
  52.     // If you are not using these features and wish to reduce the size
  53.     //  of your final executable, you should remove from the following
  54.     //  the specific initialization routines you do not need.
  55.  
  56.     SetDialogBkColor();        // Set dialog background color to gray
  57.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  58.     EnableVBX();               // Initialize VBX support
  59.     
  60.     // Load the Outline VBX file
  61.     hOLVBX = LoadVBXFile(lpszVBXFileName);
  62.  
  63.     // Register the application's document templates.  Document templates
  64.     //  serve as the connection between documents, frame windows and views.
  65.  
  66.     CMultiDocTemplate* pDocTemplate;
  67.     pDocTemplate = new CMultiDocTemplate(
  68.         IDR_TESTVBTYPE,
  69.         RUNTIME_CLASS(CTestvbxDoc),
  70.         RUNTIME_CLASS(CMDIChildWnd),        // standard MDI child frame
  71.         RUNTIME_CLASS(CTestvbxView));
  72.     AddDocTemplate(pDocTemplate);
  73.  
  74.     // create main MDI Frame window
  75.     CMainFrame* pMainFrame = new CMainFrame;
  76.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  77.         return FALSE;
  78.     m_pMainWnd = pMainFrame;
  79.  
  80.     // create a new (empty) document
  81.     OnFileNew();
  82.  
  83.     if (m_lpCmdLine[0] != '\0')
  84.     {
  85.         // TODO: add command line processing here
  86.     }
  87.  
  88.     // The main window has been initialized, so show and update it.
  89.     pMainFrame->ShowWindow(m_nCmdShow);
  90.     pMainFrame->UpdateWindow();
  91.  
  92.     return TRUE;
  93. }
  94.  
  95. int CTestvbxApp::ExitInstance()
  96. {       
  97.     if (hOLVBX >= HINSTANCE_ERROR)
  98.         UnloadVBXFile(lpszVBXFileName);
  99.         
  100.     return CWinApp::ExitInstance();        
  101. }
  102.  
  103. /////////////////////////////////////////////////////////////////////////////
  104. // CAboutDlg dialog used for App About
  105.  
  106. class CAboutDlg : public CDialog
  107. {
  108. public:
  109.     CAboutDlg();
  110.  
  111. // Dialog Data
  112.     //{{AFX_DATA(CAboutDlg)
  113.     enum { IDD = IDD_ABOUTBOX };
  114.     //}}AFX_DATA
  115.  
  116. // Implementation
  117. protected:
  118.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  119.     //{{AFX_MSG(CAboutDlg)
  120.         // No message handlers
  121.     //}}AFX_MSG
  122.     DECLARE_MESSAGE_MAP()
  123. };
  124.  
  125. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  126. {
  127.     //{{AFX_DATA_INIT(CAboutDlg)
  128.     //}}AFX_DATA_INIT
  129. }
  130.  
  131. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  132. {
  133.     CDialog::DoDataExchange(pDX);
  134.     //{{AFX_DATA_MAP(CAboutDlg)
  135.     //}}AFX_DATA_MAP
  136. }
  137.  
  138. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  139.     //{{AFX_MSG_MAP(CAboutDlg)
  140.         // No message handlers
  141.     //}}AFX_MSG_MAP
  142. END_MESSAGE_MAP()
  143.  
  144. // App command to run the dialog
  145. void CTestvbxApp::OnAppAbout()
  146. {
  147.     CAboutDlg aboutDlg;
  148.     aboutDlg.DoModal();
  149. }
  150.  
  151. /////////////////////////////////////////////////////////////////////////////
  152. // VB-Event registration
  153. // (calls to AfxRegisterVBEvent will be placed here by ClassWizard)
  154.  
  155. //{{AFX_VBX_REGISTER_MAP()
  156.     UINT NEAR VBN_OL_ADDNODE = AfxRegisterVBEvent("OL_ADDNODE");
  157.     UINT NEAR VBN_OL_CHANGENODE = AfxRegisterVBEvent("OL_CHANGENODE");
  158.     UINT NEAR VBN_ADDNODE = AfxRegisterVBEvent("ADDNODE");
  159.     UINT NEAR VBN_CHANGENODE = AfxRegisterVBEvent("CHANGENODE");
  160.     UINT NEAR VBN_INSERTNODE = AfxRegisterVBEvent("INSERTNODE");
  161.     UINT NEAR VBN_CHANGESELECTION = AfxRegisterVBEvent("CHANGESELECTION");
  162.     UINT NEAR VBN_DELETENODE = AfxRegisterVBEvent("DELETENODE");
  163.     UINT NEAR VBN_INDENTNODE = AfxRegisterVBEvent("INDENTNODE");
  164.     UINT NEAR VBN_KILLFOCUS = AfxRegisterVBEvent("KILLFOCUS");
  165.     UINT NEAR VBN_LEFTBUTTONCLICK = AfxRegisterVBEvent("LEFTBUTTONCLICK");
  166.     UINT NEAR VBN_MIDDLEBUTTONCLICK = AfxRegisterVBEvent("MIDDLEBUTTONCLICK");
  167.     UINT NEAR VBN_RIGHTBUTTONCLICK = AfxRegisterVBEvent("RIGHTBUTTONCLICK");
  168.     UINT NEAR VBN_SETFOCUS = AfxRegisterVBEvent("SETFOCUS");
  169.     UINT NEAR VBN_VERTICALSCROLL = AfxRegisterVBEvent("VERTICALSCROLL");
  170. //}}AFX_VBX_REGISTER_MAP
  171.  
  172. /////////////////////////////////////////////////////////////////////////////
  173. // CTestvbxApp commands
  174.