Advertisement
Guest User

IMDisplay.cpp

a guest
Sep 18th, 2010
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.57 KB | None | 0 0
  1. // IMDisplay.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "IMDisplay.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "ChildFrm.h"
  9. #include "IMDisplayDoc.h"
  10. #include "IMDisplayView.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. // CIMDisplayApp
  20.  
  21. BEGIN_MESSAGE_MAP(CIMDisplayApp, CWinApp)
  22.     //{{AFX_MSG_MAP(CIMDisplayApp)
  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.     // Standard print setup command
  31.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  32. END_MESSAGE_MAP()
  33.  
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CIMDisplayApp construction
  36.  
  37. CIMDisplayApp::CIMDisplayApp()
  38. {
  39.     // TODO: add construction code here,
  40.     // Place all significant initialization in InitInstance
  41. }
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // The one and only CIMDisplayApp object
  45.  
  46. CIMDisplayApp theApp;
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CIMDisplayApp initialization
  50.  
  51. BOOL CIMDisplayApp::InitInstance()
  52. {
  53.     AfxEnableControlContainer();
  54.  
  55.     // Standard initialization
  56.     // If you are not using these features and wish to reduce the size
  57.     //  of your final executable, you should remove from the following
  58.     //  the specific initialization routines you do not need.
  59.  
  60.     // Change the registry key under which our settings are stored.
  61.     // TODO: You should modify this string to be something appropriate
  62.     // such as the name of your company or organization.
  63.     SetRegistryKey(_T("ImageMagick"));
  64.  
  65.     LoadStdProfileSettings(5);  // 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.  
  72.         //TH all image types, default
  73.         pDocTemplate = new CMultiDocTemplate(
  74.             IDR_IMIMAGETYPE,
  75.             RUNTIME_CLASS(CIMDisplayDoc),
  76.             RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  77.             RUNTIME_CLASS(CIMDisplayView));
  78.     AddDocTemplate(pDocTemplate);
  79.  
  80.         // BMP
  81.     pDocTemplate = new CMultiDocTemplate(
  82.         IDR_IMBMPTYPE,
  83.         RUNTIME_CLASS(CIMDisplayDoc),
  84.         RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  85.         RUNTIME_CLASS(CIMDisplayView));
  86.     AddDocTemplate(pDocTemplate);
  87.  
  88.         // EPS
  89.         pDocTemplate = new CMultiDocTemplate(
  90.             IDR_IMEPSTYPE,
  91.             RUNTIME_CLASS(CIMDisplayDoc),
  92.             RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  93.             RUNTIME_CLASS(CIMDisplayView));
  94.     AddDocTemplate(pDocTemplate);
  95.  
  96.         // GIF
  97.         pDocTemplate = new CMultiDocTemplate(
  98.             IDR_IMGIFTYPE,
  99.             RUNTIME_CLASS(CIMDisplayDoc),
  100.             RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  101.             RUNTIME_CLASS(CIMDisplayView));
  102.     AddDocTemplate(pDocTemplate);
  103.  
  104.         // JPEG
  105.     pDocTemplate = new CMultiDocTemplate(
  106.         IDR_IMJPEGTYPE,
  107.         RUNTIME_CLASS(CIMDisplayDoc),
  108.         RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  109.         RUNTIME_CLASS(CIMDisplayView));
  110.     AddDocTemplate(pDocTemplate);
  111.  
  112.         // MIFF
  113.         pDocTemplate = new CMultiDocTemplate(
  114.             IDR_IMMIFFTYPE,
  115.             RUNTIME_CLASS(CIMDisplayDoc),
  116.             RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  117.             RUNTIME_CLASS(CIMDisplayView));
  118.     AddDocTemplate(pDocTemplate);
  119.  
  120.         // PNG
  121.     pDocTemplate = new CMultiDocTemplate(
  122.         IDR_IMPNGTYPE,
  123.         RUNTIME_CLASS(CIMDisplayDoc),
  124.         RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  125.         RUNTIME_CLASS(CIMDisplayView));
  126.     AddDocTemplate(pDocTemplate);
  127.  
  128.         // TIFF
  129.     pDocTemplate = new CMultiDocTemplate(
  130.         IDR_IMTIFFTYPE,
  131.         RUNTIME_CLASS(CIMDisplayDoc),
  132.         RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  133.         RUNTIME_CLASS(CIMDisplayView));
  134.     AddDocTemplate(pDocTemplate);
  135.  
  136.         // SVG
  137.     pDocTemplate = new CMultiDocTemplate(
  138.         IDR_IMSVGTYPE,
  139.         RUNTIME_CLASS(CIMDisplayDoc),
  140.         RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  141.         RUNTIME_CLASS(CIMDisplayView));
  142.     AddDocTemplate(pDocTemplate);
  143.  
  144.         // WMF
  145.         pDocTemplate = new CMultiDocTemplate(
  146.             IDR_IMWMFTYPE,
  147.             RUNTIME_CLASS(CIMDisplayDoc),
  148.             RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  149.             RUNTIME_CLASS(CIMDisplayView));
  150.     AddDocTemplate(pDocTemplate);
  151.  
  152.     // create main MDI Frame window
  153.     CMainFrame* pMainFrame = new CMainFrame;
  154.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  155.         return FALSE;
  156.     m_pMainWnd = pMainFrame;
  157.  
  158.     // Parse command line for standard shell commands, DDE, file open
  159.     CCommandLineInfo cmdInfo;
  160.     ParseCommandLine(cmdInfo);
  161.  
  162.     // BOGUS: find a way to generalize this!
  163.     //char  exePath[2048];
  164.     //DWORD pathSize = GetModuleFileName( NULL, exePath, 2048 );
  165.     //exePath[ pathSize ] = 0;
  166.     //char* ps = (char*)(exePath + pathSize - 1);
  167.     //while ( *ps != '\\' ) { *ps = 0; ps--; }  // shrink it!
  168.         //MagickCore::InitializeMagick( exePath );
  169.  
  170.         MagickCore::InitializeMagick( NULL );
  171.  
  172.     // we do this to init the coder list, but will use it
  173.     // more seriously in the future when we actually build up
  174.     // the list of support modules dynamically!
  175.     try {
  176.         std::list<CoderInfo> coderList;
  177.         coderInfoList( &coderList, CoderInfo::TrueMatch, CoderInfo::AnyMatch, CoderInfo::AnyMatch);
  178.         size_t numCoders = coderList.size();
  179.     }
  180.     catch(Exception e) {
  181.         e.what();
  182.     };
  183.  
  184.     // Dispatch commands specified on the command line
  185.     if (!ProcessShellCommand(cmdInfo))
  186.         return FALSE;
  187.  
  188.     // Enable drag/drop open
  189.     pMainFrame->DragAcceptFiles();
  190.  
  191.     // The main window has been initialized, so show and update it.
  192.     pMainFrame->ShowWindow(m_nCmdShow);
  193.     pMainFrame->UpdateWindow();
  194.  
  195.     return TRUE;
  196. }
  197.  
  198.  
  199. /////////////////////////////////////////////////////////////////////////////
  200. // CAboutDlg dialog used for App About
  201.  
  202. class CAboutDlg : public CDialog
  203. {
  204. public:
  205.     CAboutDlg();
  206.  
  207. // Dialog Data
  208.     //{{AFX_DATA(CAboutDlg)
  209.     enum { IDD = IDD_ABOUTBOX };
  210.     //}}AFX_DATA
  211.  
  212.     // ClassWizard generated virtual function overrides
  213.     //{{AFX_VIRTUAL(CAboutDlg)
  214.     protected:
  215.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  216.     //}}AFX_VIRTUAL
  217.  
  218. // Implementation
  219. protected:
  220.     //{{AFX_MSG(CAboutDlg)
  221.         // No message handlers
  222.     //}}AFX_MSG
  223.     DECLARE_MESSAGE_MAP()
  224. public:
  225.     virtual BOOL OnInitDialog();
  226. };
  227.  
  228. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  229. {
  230.     //{{AFX_DATA_INIT(CAboutDlg)
  231.     //}}AFX_DATA_INIT
  232. }
  233.  
  234. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  235. {
  236.     CDialog::DoDataExchange(pDX);
  237.     //{{AFX_DATA_MAP(CAboutDlg)
  238.     //}}AFX_DATA_MAP
  239. }
  240.  
  241. BOOL CAboutDlg::OnInitDialog()
  242. {
  243.     CDialog::OnInitDialog();
  244.  
  245.     // TODO:  Add extra initialization here
  246.     SetDlgItemText (IDC_STATIC_VERSION, CString("Version: ") + MagickVersion); //TH
  247.  
  248.     return TRUE;  // return TRUE unless you set the focus to a control
  249.     // EXCEPTION: OCX Property Pages should return FALSE
  250. }
  251.  
  252.  
  253. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  254.     //{{AFX_MSG_MAP(CAboutDlg)
  255.         // No message handlers
  256.     //}}AFX_MSG_MAP
  257. END_MESSAGE_MAP()
  258.  
  259. // App command to run the dialog
  260. void CIMDisplayApp::OnAppAbout()
  261. {
  262.     CAboutDlg aboutDlg;
  263.     aboutDlg.DoModal();
  264. }
  265.  
  266. /////////////////////////////////////////////////////////////////////////////
  267. // CIMDisplayApp message handlers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement