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

  1. // draw.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "draw.h"
  6.  
  7. #include "Maindraw.h"
  8. #include "Childdrw.h"
  9. #include "drawDoc.h"
  10. #include "drawView.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. // CDrawApp
  22.  
  23. BEGIN_MESSAGE_MAP(CDrawApp, CWinApp)
  24.     //{{AFX_MSG_MAP(CDrawApp)
  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_NEW, CWinApp::OnFileNew)
  30.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  31. END_MESSAGE_MAP()
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CDrawApp construction
  35.  
  36. CDrawApp::CDrawApp()
  37. {
  38.     // TODO: add construction code here,
  39.     // Place all significant initialization in InitInstance
  40. }
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // The one and only CDrawApp object
  44.  
  45. CDrawApp theApp;
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CDrawApp initialization
  49.  
  50. BOOL CDrawApp::InitInstance()
  51. {
  52.     AfxEnableControlContainer();
  53.  
  54.     // Standard initialization
  55.     // If you are not using these features and wish to reduce the size
  56.     //  of your final executable, you should remove from the following
  57.     //  the specific initialization routines you do not need.
  58.  
  59. #ifdef _AFXDLL
  60.     Enable3dControls();            // Call this when using MFC in a shared DLL
  61. #else
  62.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  63. #endif
  64.  
  65.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  66.  
  67.     // Register the application's document templates.  Document templates
  68.     //  serve as the connection between documents, frame windows and views.
  69.  
  70.     CMultiDocTemplate* pDocTemplate;
  71.     pDocTemplate = new CMultiDocTemplate(
  72.         IDR_DRAWTYPE,
  73.         RUNTIME_CLASS(CDrawDoc),
  74.         RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  75.         RUNTIME_CLASS(CDrawView));
  76.     AddDocTemplate(pDocTemplate);
  77.  
  78.     // create main MDI Frame window
  79.     CMainFrame* pMainFrame = new CMainFrame;
  80.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  81.         return FALSE;
  82.     m_pMainWnd = pMainFrame;
  83.  
  84.     // The main window has been initialized, so show and update it.
  85.     pMainFrame->ShowWindow(m_nCmdShow);
  86.     pMainFrame->UpdateWindow();
  87.  
  88.     return TRUE;
  89. }
  90.  
  91. /////////////////////////////////////////////////////////////////////////////
  92. // CAboutDlg dialog used for App About
  93.  
  94. class CAboutDlg : public CDialog
  95. {
  96. public:
  97.     CAboutDlg();
  98.  
  99. // Dialog Data
  100.     //{{AFX_DATA(CAboutDlg)
  101.     enum { IDD = IDD_ABOUTBOX };
  102.     //}}AFX_DATA
  103.  
  104.     // ClassWizard generated virtual function overrides
  105.     //{{AFX_VIRTUAL(CAboutDlg)
  106.     protected:
  107.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  108.     //}}AFX_VIRTUAL
  109.  
  110. // Implementation
  111. protected:
  112.     //{{AFX_MSG(CAboutDlg)
  113.         // No message handlers
  114.     //}}AFX_MSG
  115.     DECLARE_MESSAGE_MAP()
  116. };
  117.  
  118. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  119. {
  120.     //{{AFX_DATA_INIT(CAboutDlg)
  121.     //}}AFX_DATA_INIT
  122. }
  123.  
  124. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  125. {
  126.     CDialog::DoDataExchange(pDX);
  127.     //{{AFX_DATA_MAP(CAboutDlg)
  128.     //}}AFX_DATA_MAP
  129. }
  130.  
  131. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  132.     //{{AFX_MSG_MAP(CAboutDlg)
  133.         // No message handlers
  134.     //}}AFX_MSG_MAP
  135. END_MESSAGE_MAP()
  136.  
  137. // App command to run the dialog
  138. void CDrawApp::OnAppAbout()
  139. {
  140.     CAboutDlg aboutDlg;
  141.     aboutDlg.DoModal();
  142. }
  143.  
  144. /////////////////////////////////////////////////////////////////////////////
  145. // CDrawApp commands
  146. CLead* CDrawApp::GetMainLead()
  147. {
  148.     CMainFrame* pFrame;
  149.     pFrame = (CMainFrame*)m_pMainWnd;
  150.     if(!pFrame)
  151.         return(NULL);
  152.     return(pFrame->m_pLead);
  153. }
  154.  
  155. int CDrawApp::DisplayLEADError(int nCode)
  156. {
  157.     CString str;
  158.  
  159.     if(nCode)
  160.     {
  161.         str.Format("A LEADTOOLS error has occured.\nCODE = %d", nCode);
  162.         m_pMainWnd->MessageBox(str);
  163.     }
  164.     return(nCode);
  165. }
  166.  
  167. void CDrawApp::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.