home *** CD-ROM | disk | FTP | other *** search
- // MirrorIt.cpp : Defines the class behaviors for the application.
- //
-
- #include "stdafx.h"
- #include "MirrorIt.h"
-
- #include "MainFrm.h"
- #include "MirrorItDoc.h"
- #include "MirrorItView.h"
- #include <stdio.h>
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CMirrorItApp
-
- BEGIN_MESSAGE_MAP(CMirrorItApp, CWinApp)
- //{{AFX_MSG_MAP(CMirrorItApp)
- ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
- //}}AFX_MSG_MAP
- // Standard file based document commands
- ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
- ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CMirrorItApp construction
-
- CMirrorItApp::CMirrorItApp()
- {
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
- // theDumpFile.Open("C:\\1.txt", CFile::modeCreate | CFile::modeWrite);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // The one and only CMirrorItApp object
-
- CMirrorItApp theApp;
-
- /////////////////////////////////////////////////////////////////////////////
- // CMirrorItApp initialization
-
- BOOL CMirrorItApp::InitInstance()
- {
- if (!AfxSocketInit())
- {
- AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
- return FALSE;
- }
-
- AfxEnableControlContainer();
-
- // Standard initialization
- // If you are not using these features and wish to reduce the size
- // of your final executable, you should remove from the following
- // the specific initialization routines you do not need.
-
- #ifdef _AFXDLL
- Enable3dControls(); // Call this when using MFC in a shared DLL
- #else
- Enable3dControlsStatic(); // Call this when linking to MFC statically
- #endif
-
- // Change the registry key under which our settings are stored.
- // You should modify this string to be something appropriate
- // such as the name of your company or organization.
- SetRegistryKey(_T("CoDe"));
-
- LoadStdProfileSettings(); // Load standard INI file options (including MRU)
- LoadMimeTypes();
-
- // Register the application's document templates. Document templates
- // serve as the connection between documents, frame windows and views.
-
- CSingleDocTemplate* pDocTemplate;
- pDocTemplate = new CSingleDocTemplate(
- IDR_MAINFRAME,
- RUNTIME_CLASS(CMirrorItDoc),
- RUNTIME_CLASS(CMainFrame), // main SDI frame window
- RUNTIME_CLASS(CMirrorItView));
- AddDocTemplate(pDocTemplate);
-
- // Enable DDE Execute open
- EnableShellOpen();
- RegisterShellFileTypes(TRUE);
-
- // Parse command line for standard shell commands, DDE, file open
- CCommandLineInfo cmdInfo;
- ParseCommandLine(cmdInfo);
-
- // Dispatch commands specified on the command line
- if (!ProcessShellCommand(cmdInfo))
- return FALSE;
-
- // The one and only window has been initialized, so show and update it.
- m_pMainWnd->ShowWindow(SW_SHOW);
- m_pMainWnd->UpdateWindow();
-
- // Enable drag/drop open
- m_pMainWnd->DragAcceptFiles();
-
- return TRUE;
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
-
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
-
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
-
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
-
- // Implementation
- protected:
- //{{AFX_MSG(CAboutDlg)
- // No message handlers
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
-
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
-
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- // App command to run the dialog
- void CMirrorItApp::OnAppAbout()
- {
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMirrorItApp commands
-
- void CMirrorItApp::LoadMimeTypes()
- {
- int i = GetProfileInt("MimeTypes", "count", -1);
- if (i == -1)
- {
- HANDLE resloc, res;
-
- resloc = FindResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MIMETYPES), "MIMETYPES");
- if ((res = LoadResource(AfxGetInstanceHandle(), (HRSRC) resloc)) == 0) return;
- LPSTR str = (LPTSTR) LockResource(res);
- LPSTR strend = str + SizeofResource(AfxGetInstanceHandle(), (HRSRC) resloc);
-
- CString temp;
-
- i = 0;
- while (str < strend)
- {
- if (*str == '\n')
- {
- AddMimeType(temp, i);
- }
- else
- if (*str != '\r')
- {
- temp += *str;
- }
- str++;
- }
-
- AddMimeType(temp, i);
-
- WriteProfileInt("MimeTypes", "count", i);
-
- UnlockResource(res);
- FreeResource(res);
- }
- else
- {
- for (int j = 0; j < i; j++)
- {
- CString temp;
- char buf[10];
-
- sprintf(buf, "%ld", j);
- temp = GetProfileString("MimeTypes", buf);
- if (!temp.IsEmpty())
- m_MimeTypes.AddTail(temp);
- }
- }
-
- }
-
- void CMirrorItApp::AddMimeType(CString & temp, int & i)
- {
- if (!temp.IsEmpty())
- {
- char buf[10];
- sprintf(buf, "%ld", i);
- WriteProfileString("MimeTypes", buf, (LPCSTR) temp);
- i++;
- m_MimeTypes.AddTail(temp);
- }
- temp.Empty();
- }
-
- int CMirrorItApp::ExitInstance()
- {
- // theDumpFile.Close();
-
- return CWinApp::ExitInstance();
- }
-
-
- void CMirrorItApp::WinHelp(DWORD dwData, UINT nCmd)
- {
- #if 0
- CString dir, help = m_pszHelpFilePath;
-
- dir = help = help.Left(help.ReverseFind('\\'));
- help += "\\html\\";
- // AfxMessageBox(help);
- if (nCmd == HELP_CONTEXT)
- {
- switch(dwData)
- {
- case 0x10000 + ID_FILE_NEW:
- case 0x10000 + ID_FILE_OPEN:
- case 0x10000 + ID_FILE_SAVE:
- case 0x10000 + ID_FILE_SAVE_AS:
- case 0x10000 + ID_APP_EXIT:
- case 0x20000 + AFX_IDD_FILEOPEN:
- case 0x20000 + AFX_IDD_FILESAVE:
- help += "filemenu.html";
- break;
-
- case 0x10000 + ID_EDIT_CLEAR:
- case 0x10000 + ID_EDIT_COPY:
- case 0x10000 + ID_EDIT_CUT:
- case 0x10000 + ID_EDIT_PASTE:
- help += "editmenu.html";
- break;
-
- case 0x10000 + IDM_VIEW_LARGEICONS:
- case 0x10000 + IDM_VIEW_SMALLICONS:
- case 0x10000 + IDM_VIEW_LIST:
- case 0x10000 + IDM_VIEW_DETAILS:
- case 0x10000 + ID_VIEW_TOOLBAR:
- case 0x10000 + ID_VIEW_STATUS_BAR:
- help += "viewmenu.html";
- break;
-
- case 0x10000 + ID_SESSION_ADD:
- case 0x10000 + ID_SESSION_REMOVE:
- case 0x10000 + ID_SESSION_PROPERTIES:
- case 0x10000 + ID_SESSION_MOVEUP:
- case 0x10000 + ID_SESSION_MOVEDOWN:
- case 0x10000 + ID_SESSION_START:
- help += "sessionmenu.html";
- break;
-
- case 0x20000 + IDD_ABOUTBOX:
- case 0x10000 + ID_APP_ABOUT:
- help += "copyright.html";
- break;
-
- case 0x20000 + IDD_DOWNLOAD:
- help += "sessionmenustartdownloading.html";
- break;
-
- case 0x20000 + IDD_SESSIONPROPERTIESMAIN:
- help += "editmenupropertiesgeneral.html";
- break;
-
- case 0x20000 + IDD_SESSIONPROPERTIESMIRROR:
- help += "editmenupropertiesmirror.html";
- break;
-
- case 0x20000 + IDD_SESSIONPROPERTIESFILENAMES:
- help += "editmenupropertiesfilenames.html";
- break;
-
- case 0x20000 + IDD_SESSIONPROPERTIESFILETYPES:
- help += "editmenupropertiesmimetypes.html";
- break;
-
- case 0x20000 + IDD_SESSIONPROPERTIESLIMITS:
- help += "editmenupropertieslimits.html";
- break;
-
- case 0x20000 + IDD_SESSIONPROPERTIESADVANCED:
- help += "editmenupropertiesadvanced.html";
- break;
-
- case 0x20000 + IDD_SESSIONPROPERTIESPROXY:
- help += "editmenupropertiesproxy.html";
- break;
-
- case 0x20000 + IDD_SESSIONPROPERTIESPASSWORD:
- help += "editmenupropertiesauthentication.html";
- break;
-
- default:
- help += "index.html";
- }
- }
- else
- {
- help += "index.html";
- }
-
- int i = (int)::ShellExecute(0, NULL, (LPCSTR)help, NULL, (LPCSTR)dir, SW_SHOWNORMAL);
- if (i < 32)
- {
- AfxMessageBox(IDS_HELPERROR, MB_OK | MB_ICONEXCLAMATION);
- }
- #endif
- // CWinApp::WinHelp(dwData, nCmd);
- }
-