home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / leadtools / ocx32.lt / Scrdemo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-03  |  5.4 KB  |  201 lines

  1. // ScrDemo.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "ScrDemo.h"
  6. #include "ScrMain.h"
  7. #include "ScrChild.h"
  8. #include "ScrDoc.h"
  9. #include "ScrView.h"
  10. #include "..\\..\\..\\..\\include\\ltscrocx.h"
  11.  
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18.  
  19.  
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CScrDemo
  22.  
  23. BEGIN_MESSAGE_MAP(CScrDemo, CWinApp)
  24.     //{{AFX_MSG_MAP(CScrDemo)
  25.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  26.     ON_COMMAND(ID_FILE_NEW, OnFileNew)
  27.     ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  28.     //}}AFX_MSG_MAP
  29.     // Standard file based document commands
  30.     //ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  31.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  32.     // Standard print setup command
  33.     //ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  34. END_MESSAGE_MAP()
  35.  
  36. BEGIN_EVENTSINK_MAP(CScrDemo, CWinApp)
  37.     ON_EVENT(CScrDemo, IDC_CAPTUREWINDOW, 1 /* OnCaptueImage */, OnImageCaptured, VTS_I4)
  38. END_EVENTSINK_MAP()
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CScrDemo construction
  42.  
  43. CScrDemo::CScrDemo()
  44. {
  45.     // TODO: add construction code here,
  46.     // Place all significant initialization in InitInstance
  47.     m_LeadBitmap = NULL;
  48. }
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // The one and only CScrDemo object
  52.  
  53. CScrDemo theApp;
  54.  
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CScrDemo initialization
  57.  
  58. BOOL CScrDemo::InitInstance()
  59. {
  60.     AfxEnableControlContainer();
  61.  
  62.     // Standard initialization
  63.     // If you are not using these features and wish to reduce the size
  64.     //  of your final executable, you should remove from the following
  65.     //  the specific initialization routines you do not need.
  66.  
  67. #ifdef _AFXDLL
  68.     Enable3dControls();            // Call this when using MFC in a shared DLL
  69. #else
  70.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  71. #endif
  72.  
  73.     // Change the registry key under which our settings are stored.
  74.     // You should modify this string to be something appropriate
  75.     // such as the name of your company or organization.
  76.     SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  77.  
  78.     LoadStdProfileSettings(7);  // Load standard INI file options (including MRU)
  79.  
  80.     // Register the application's document templates.  Document templates
  81.     //  serve as the connection between documents, frame windows and views.
  82.  
  83.     CMultiDocTemplate* pDocTemplate;
  84.     pDocTemplate = new CMultiDocTemplate(
  85.         IDR_SCRDEMTYPE,
  86.         RUNTIME_CLASS(CScrDoc),
  87.         RUNTIME_CLASS(CScrChild), // custom MDI child frame
  88.         RUNTIME_CLASS(CScrView));
  89.     AddDocTemplate(pDocTemplate);
  90.  
  91.     // create main MDI Frame window
  92.     CScrMain* pMainFrame = new CScrMain;
  93.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  94.         return FALSE;
  95.     m_pMainWnd = pMainFrame;
  96.  
  97.     // Parse command line for standard shell commands, DDE, file open
  98.     CCommandLineInfo cmdInfo;
  99.     ParseCommandLine(cmdInfo);
  100.  
  101.     // Dispatch commands specified on the command line
  102.     if (!ProcessShellCommand(cmdInfo))
  103.         return FALSE;
  104.  
  105.     // The main window has been initialized, so show and update it.
  106.     pMainFrame->ShowWindow(m_nCmdShow);
  107.     pMainFrame->UpdateWindow();
  108.  
  109.     return TRUE;
  110. }
  111.  
  112. /////////////////////////////////////////////////////////////////////////////
  113. // CAboutDlg dialog used for App About
  114.  
  115. class CAboutDlg : public CDialog
  116. {
  117. public:
  118.     CAboutDlg();
  119.  
  120. // Dialog Data
  121.     //{{AFX_DATA(CAboutDlg)
  122.     enum { IDD = IDD_ABOUTBOX };
  123.     //}}AFX_DATA
  124.  
  125.     // ClassWizard generated virtual function overrides
  126.     //{{AFX_VIRTUAL(CAboutDlg)
  127.     protected:
  128.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  129.     //}}AFX_VIRTUAL
  130.  
  131. // Implementation
  132. protected:
  133.     //{{AFX_MSG(CAboutDlg)
  134.         // No message handlers
  135.     //}}AFX_MSG
  136.     DECLARE_MESSAGE_MAP()
  137. };
  138.  
  139. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  140. {
  141.     //{{AFX_DATA_INIT(CAboutDlg)
  142.     //}}AFX_DATA_INIT
  143. }
  144.  
  145. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  146. {
  147.     CDialog::DoDataExchange(pDX);
  148.     //{{AFX_DATA_MAP(CAboutDlg)
  149.     //}}AFX_DATA_MAP
  150. }
  151.  
  152. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  153.     //{{AFX_MSG_MAP(CAboutDlg)
  154.         // No message handlers
  155.     //}}AFX_MSG_MAP
  156. END_MESSAGE_MAP()
  157.  
  158. // App command to run the dialog
  159. void CScrDemo::OnAppAbout()
  160. {
  161.     CAboutDlg aboutDlg;
  162.     aboutDlg.DoModal();
  163. }
  164.  
  165. /////////////////////////////////////////////////////////////////////////////
  166. // CScrDemo commands
  167.  
  168.  
  169. void CScrDemo::OnImageCaptured(long CaptureNumber)
  170. {
  171.     CScrMain * pMain = (CScrMain *) AfxGetMainWnd();
  172.     m_LeadBitmap = (HGLOBAL)pMain->m_CapOCX.GetBitmap();
  173.     if (m_LeadBitmap)
  174.         CWinApp::OnFileNew();    
  175.  
  176. }
  177.  
  178. void CScrDemo::OnFileNew() 
  179. {
  180.     // TODO: Add your command handler code here
  181.     //Does nothing.
  182. }
  183.  
  184. void CScrDemo::OnFileOpen() 
  185. {
  186.     // TODO: Add your command handler code here
  187.    CString   m_FileName;
  188.    CScrMain *m_pMainFrame = (CScrMain*)AfxGetMainWnd ();
  189.  
  190.    LPSTR pszFilter = "Executable files(*.EXE)|*.exe|Dynamic Link Libraries(*.DLL)|*.dll|All files(*.*)|*.*|";
  191.    CFileDialog COpen( TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_FILEMUSTEXIST,pszFilter);
  192.  
  193.    if (COpen.DoModal()==IDOK)
  194.    {
  195.       CScrMain *pMain = (CScrMain *) AfxGetMainWnd();
  196.       m_FileName = COpen.GetPathName();
  197.       AddToRecentFileList(m_FileName);
  198.       m_pMainFrame->m_CapOCX.CaptureEXEDlg ((short)m_pMainFrame->m_hWnd, (LPCTSTR)m_FileName, 0, SCR_CAP_EXEDLG_TREEVIEW);
  199.    }
  200. }
  201.