home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / leadtools / ocx32.lt / Magnify.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-13  |  5.0 KB  |  194 lines

  1. // magnify.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "magnify.h"
  6.  
  7. #include "Mainmagn.h"
  8. #include "Childmgn.h"
  9. #include "magnDoc.h"
  10. #include "magnView.h"
  11. #include "LeadDlg.h"
  12. #include "..\..\..\..\include\ltdlgocx.h"
  13.  
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19.  
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CMagnifyApp
  22.  
  23. BEGIN_MESSAGE_MAP(CMagnifyApp, CWinApp)
  24.     //{{AFX_MSG_MAP(CMagnifyApp)
  25.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  26.     ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  27.     //}}AFX_MSG_MAP
  28.     // Standard file based document commands
  29.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  30. END_MESSAGE_MAP()
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CMagnifyApp construction
  34.  
  35. CMagnifyApp::CMagnifyApp()
  36. {
  37.     // TODO: add construction code here,
  38.     // Place all significant initialization in InitInstance
  39. }
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // The one and only CMagnifyApp object
  43.  
  44. CMagnifyApp theApp;
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CMagnifyApp initialization
  48.  
  49. BOOL CMagnifyApp::InitInstance()
  50. {
  51.     AfxEnableControlContainer();
  52.  
  53.     // Standard initialization
  54.     // If you are not using these features and wish to reduce the size
  55.     //  of your final executable, you should remove from the following
  56.     //  the specific initialization routines you do not need.
  57.  
  58. #ifdef _AFXDLL
  59.     Enable3dControls();            // Call this when using MFC in a shared DLL
  60. #else
  61.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  62. #endif
  63.  
  64.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  65.  
  66.     // Register the application's document templates.  Document templates
  67.     //  serve as the connection between documents, frame windows and views.
  68.  
  69.     CMultiDocTemplate* pDocTemplate;
  70.     pDocTemplate = new CMultiDocTemplate(
  71.         IDR_MAGNIFTYPE,
  72.         RUNTIME_CLASS(CMagnifyDoc),
  73.         RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  74.         RUNTIME_CLASS(CMagnifyView));
  75.     AddDocTemplate(pDocTemplate);
  76.  
  77.     // create main MDI Frame window
  78.     CMainFrame* pMainFrame = new CMainFrame;
  79.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  80.         return FALSE;
  81.     m_pMainWnd = pMainFrame;
  82.  
  83.     // Parse command line for standard shell commands, DDE, file open
  84.     CCommandLineInfo cmdInfo;
  85.     ParseCommandLine(cmdInfo);
  86.  
  87.     // Dispatch commands specified on the command line
  88.     // disable the creation of a new document
  89. //    if (!ProcessShellCommand(cmdInfo))
  90. //        return FALSE;
  91.  
  92.     // The main window has been initialized, so show and update it.
  93.     pMainFrame->ShowWindow(m_nCmdShow);
  94.     pMainFrame->UpdateWindow();
  95.  
  96.     return TRUE;
  97. }
  98.  
  99. /////////////////////////////////////////////////////////////////////////////
  100. // CAboutDlg dialog used for App About
  101.  
  102. class CAboutDlg : public CDialog
  103. {
  104. public:
  105.     CAboutDlg();
  106.  
  107. // Dialog Data
  108.     //{{AFX_DATA(CAboutDlg)
  109.     enum { IDD = IDD_ABOUTBOX };
  110.     //}}AFX_DATA
  111.  
  112.     // ClassWizard generated virtual function overrides
  113.     //{{AFX_VIRTUAL(CAboutDlg)
  114.     protected:
  115.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  116.     //}}AFX_VIRTUAL
  117.  
  118. // Implementation
  119. protected:
  120.     //{{AFX_MSG(CAboutDlg)
  121.         // No message handlers
  122.     //}}AFX_MSG
  123.     DECLARE_MESSAGE_MAP()
  124. };
  125.  
  126. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  127. {
  128.     //{{AFX_DATA_INIT(CAboutDlg)
  129.     //}}AFX_DATA_INIT
  130. }
  131.  
  132. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  133. {
  134.     CDialog::DoDataExchange(pDX);
  135.     //{{AFX_DATA_MAP(CAboutDlg)
  136.     //}}AFX_DATA_MAP
  137. }
  138.  
  139. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  140.     //{{AFX_MSG_MAP(CAboutDlg)
  141.         // No message handlers
  142.     //}}AFX_MSG_MAP
  143. END_MESSAGE_MAP()
  144.  
  145. // App command to run the dialog
  146. void CMagnifyApp::OnAppAbout()
  147. {
  148.     CAboutDlg aboutDlg;
  149.     aboutDlg.DoModal();
  150. }
  151.  
  152. /////////////////////////////////////////////////////////////////////////////
  153. // CMagnifyApp commands
  154. int CMagnifyApp::DisplayLEADError(int nCode)
  155. {
  156.     CString str;
  157.  
  158.     if(nCode)
  159.     {
  160.         str.Format("A LEADTOOLS error has occured.\nCODE = %d", nCode);
  161.         m_pMainWnd->MessageBox(str);
  162.     }
  163.     return(nCode);
  164. }
  165.  
  166.  
  167. void CMagnifyApp::OnFileOpen() 
  168. {
  169.    CLeadDlg LTCommDlg;
  170.    RECT rcWin;
  171.    BOOL bContinue=FALSE;
  172.    int nRet;
  173.    
  174.    ::SetRect(&rcWin, 0, 0, 1, 1);
  175.  
  176.    if(LTCommDlg.Create(NULL,0,rcWin,m_pMainWnd,100))
  177.    {
  178.       LTCommDlg.SetEnableMethodErrors(FALSE);
  179.       LTCommDlg.SetFilter("Graphics|*.cmp;*.jpg;*.jff;*.jtf;*.bmp;*.tif;*.tga;*.pcx;*.cal;*.mac;*.mac;*.img;*.msp;*.wpg;*.wpg;*.ras;*.pct;*.pcd;*.eps;*.wmf");
  180.       LTCommDlg.SetFileDlgFlags(0);
  181.       LTCommDlg.SetDialogTitle("Open File");
  182.       LTCommDlg.SetUIFlags( DLG_FO_FILEINFO |
  183.                             DLG_FO_SHOWPREVIEW |
  184.                             DLG_FO_SHOWSTAMP |
  185.                             DLG_FO_95STYLE );
  186.       nRet = LTCommDlg.FileOpen((long)m_pMainWnd->m_hWnd);
  187.       if(nRet == 0)
  188.          bContinue = TRUE;
  189.    }
  190.    if(bContinue)
  191.       OpenDocumentFile((LPCTSTR)LTCommDlg.GetFileName());
  192.    return;
  193. }
  194.