// MyAppp.cpp : Définit les comportements de classe pour l'application. // #include "stdafx.h" #include "afxwinappex.h" #include "afxdialogex.h" #include "MyAppp.h" #include "MainFrm.h" #include "MyApppDoc.h" #include "MyApppView.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CMyApppApp BEGIN_MESSAGE_MAP(CMyApppApp, CWinAppEx) ON_COMMAND(ID_APP_ABOUT, &CMyApppApp::OnAppAbout) // Commandes de fichier standard ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) // Commande standard de configuration de l'impression ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup) END_MESSAGE_MAP() // construction CMyApppApp CMyApppApp::CMyApppApp() { m_bHiColorIcons = TRUE; // prend en charge le Gestionnaire de redémarrage m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS; #ifdef _MANAGED // Si l'application est créée à l'aide de la prise en charge Common Language Runtime (/clr): // 1) Ce paramètre supplémentaire est nécessaire à la prise en charge du Gestionnaire de redémarrage. // 2) Dans votre projet, vous devez ajouter une référence à System.Windows.Forms pour la génération. System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException); #endif // TODO: remplacer la chaîne d'ID de l'application ci-dessous par une chaîne ID unique ; le format recommandé // pour la chaîne est CompanyName.ProductName.SubProduct.VersionInformation SetAppID(_T("MyAppp.AppID.NoVersion")); // TODO: ajoutez ici du code de construction, // Placez toutes les initialisations significatives dans InitInstance } // Seul et unique objet CMyApppApp CMyApppApp theApp; // initialisation de CMyApppApp BOOL CMyApppApp::InitInstance() { int nArgs; LPWSTR *commandline; CString ExecutablePath; CString m_argument = NULL; CString m_argLowerCase = NULL; /*LPWSTR ProjectPath = NULL; int StartAddressParam = -1; int LengthParam = -1 ; bool ConvertHex = FALSE; int convertIssue = -1; CString TempHexFile; */ bool SilenceModeIsEnable = false; bool NegativeAnswer = false; errno_t err = 0; // InitCommonControlsEx() est requis sur Windows XP si le manifeste de l'application // spécifie l'utilisation de ComCtl32.dll version 6 ou ultérieure pour activer les // styles visuels. Dans le cas contraire, la création de fenêtres échouera. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // À définir pour inclure toutes les classes de contrôles communs à utiliser // dans votre application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); commandline = CommandLineToArgvW(GetCommandLineW(), &nArgs); // Force CString to make a copy CString temp = (CString)commandline[0]; // Force CString to make a copy ::PathRemoveFileSpec(temp.GetBuffer(0)); temp.ReleaseBuffer(-1); ExecutablePath = temp; //read all argument for(int i = 1; i < nArgs; i++) { m_argument = (CString) commandline[i]; m_argument.ReleaseBuffer(-1); m_argLowerCase = m_argument; m_argLowerCase.MakeLower(); if(m_argLowerCase == "-s") { SilenceModeIsEnable = TRUE; } if(m_argLowerCase == "-neg") { NegativeAnswer = TRUE; } } if(SilenceModeIsEnable == TRUE) { // convert is launched and status is 1 if OK or not ok (path incorrect....) if(NegativeAnswer == TRUE) { return_code = -2; } else { return_code = -1; } PostQuitMessage(return_code); ExitInstance(); return FALSE; } else //use the GUI { CWinAppEx::InitInstance(); // Initialiser les bibliothèques OLE if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(FALSE); // AfxInitRichEdit2() est requis pour utiliser un contrôle RichEdit // AfxInitRichEdit2(); // Initialisation standard // Si vous n'utilisez pas ces fonctionnalités et que vous souhaitez réduire la taille // de votre exécutable final, vous devez supprimer ci-dessous // les routines d'initialisation spécifiques dont vous n'avez pas besoin. // Changez la clé de Registre sous laquelle nos paramètres sont enregistrés // TODO: modifiez cette chaîne avec des informations appropriées, // telles que le nom de votre société ou organisation SetRegistryKey(_T("Applications locales générées par AppWizard")); LoadStdProfileSettings(4); // Charge les options de fichier INI standard (y compris les derniers fichiers utilisés) InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); // Inscrire les modèles de document de l'application. Ces modèles // lient les documents, fenêtres frame et vues entre eux CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CMyApppDoc), RUNTIME_CLASS(CMainFrame), // fenêtre frame SDI principale RUNTIME_CLASS(CMyApppView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // Analyser la ligne de commande pour les commandes shell standard, DDE, ouverture de fichiers CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Commandes de dispatch spécifiées sur la ligne de commande. Retournent FALSE si // l'application a été lancée avec /RegServer, /Register, /Unregserver ou /Unregister. if (!ProcessShellCommand(cmdInfo)) return FALSE; // La seule fenêtre a été initialisée et peut donc être affichée et mise à jour m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); // appelle DragAcceptFiles uniquement s'il y a un suffixe // Dans une application SDI, cet appel doit avoir lieu juste après ProcessShellCommand return TRUE; } } int CMyApppApp::ExitInstance() { //TODO: gérez les ressources supplémentaires que vous avez ajoutées AfxOleTerm(FALSE); return CWinAppEx::ExitInstance(); } // gestionnaires de messages pour CMyApppApp // boîte de dialogue CAboutDlg utilisée pour la boîte de dialogue 'À propos de' pour votre application class CAboutDlg : public CDialogEx { public: CAboutDlg(); // Données de boîte de dialogue enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // Prise en charge de DDX/DDV // Implémentation protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) END_MESSAGE_MAP() // Commande App pour exécuter la boîte de dialogue void CMyApppApp::OnAppAbout() { CAboutDlg aboutDlg; aboutDlg.DoModal(); } // CMyApppApp, méthodes de chargement/d'enregistrement de la personnalisation void CMyApppApp::PreLoadState() { BOOL bNameValid; CString strName; bNameValid = strName.LoadString(IDS_EDIT_MENU); ASSERT(bNameValid); GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT); } void CMyApppApp::LoadCustomState() { } void CMyApppApp::SaveCustomState() { } // gestionnaires de messages pour CMyApppApp