void CSDKAPWZAppWiz::CustomizeProject(IBuildProject* pProject) { // TODO: Add code here to customize the project. If you don't wish // to customize project, you may remove this virtual override. // This is called immediately after the default Debug and Release // configurations have been created for each platform. You may customize // existing configurations on this project by using the methods // of IBuildProject and IConfiguration such as AddToolSettings, // RemoveToolSettings, and AddCustomBuildStep. These are documented in // the Developer Studio object model documentation. // WARNING!! IBuildProject and all interfaces you can get from it are OLE // COM interfaces. You must be careful to release all new interfaces // you acquire. In accordance with the standard rules of COM, you must // NOT release pProject, unless you explicitly AddRef it, since pProject // is passed as an "in" parameter to this function. See the documentation // on CCustomAppWiz::CustomizeProject for more information. //The following sets the project settings for 'Addtional include directories:' //maxsdk/include, maxsdk/lib and 'Output file name:' 3dsmax/plugin/*.* CString sPath, pPath, ePath, sInc, sRC, sL, sG, pName, pExt; IConfigurations *pConfigs; long count; IConfiguration *pConfig; CString base_address; // Generate a random 64K mutliple base address int K64 = 64*1024; base_address.Format(_T("0x%x"), ((rand() + rand() + ((rand()+(rand()<<16))))/K64)*K64); lookup_key(_T("root"), pName); lookup_key(_T("PLUGEXT"), pExt); lookup_key(_T("SDKPATH"), sPath); lookup_key(_T("PLGPATH"), pPath); lookup_key(_T("EXEPATH"), ePath); // pName.SetAt(0, toupper(pName[0])); // 3dsmax.exe and maxsdk include paths sInc = "/I" + sPath + "\\include "; // Linker settings sL = //output filename "/out:" + pPath + "\\" + pName + "." + pExt + " " + //sdk libs " comctl32.lib " + GetPluginLibs(pExt) + //maxsdk libpath " /LIBPATH:" + sPath + "\\lib " + " /DLL /base:" + base_address; // General Settings sG = CString("0"); //To specify Not Using MFC BSTR bszComp = CString("cl.exe").AllocSysString(); BSTR bszLink = CString("link.exe").AllocSysString(); BSTR bszMfc = CString("mfc").AllocSysString(); // Compiler settings BSTR bszSettingsC[] = { ("/MDd /G6 /LD " + sInc).AllocSysString(), // Debug ("/MD /G6 /LD " + sInc).AllocSysString(), // Hybrid ("/MD /G6 /LD " + sInc).AllocSysString() // Release }; BSTR bszRemSettingsC = CString(_T("/GX /D_MBCS /GZ")).AllocSysString(); BSTR bszHyb = CString("Hybrid").AllocSysString(); BSTR bszSettingsL = sL.AllocSysString(); BSTR bszSettingsG = sG.AllocSysString(); COleVariant res; pProject->AddConfiguration(bszHyb, res); pProject->get_Configurations(&pConfigs); pConfigs->get_Count(&count); for (long i = 1; i <= count; i++) { COleVariant varInd(i); pConfigs->Item(varInd , &pConfig); COleVariant var(0L,VT_ERROR); var.scode=DISP_E_PARAMNOTFOUND; pConfig->AddToolSettings(bszMfc, bszSettingsG, var); pConfig->AddToolSettings(bszLink, bszSettingsL, var); COleVariant varStr; pConfig->get_Name(&V_BSTR(&varStr)); varStr.vt = VT_BSTR; if (varStr == COleVariant(pName + " - Win32 Debug")) { pConfig->AddToolSettings(bszComp, bszSettingsC[0], var); SysFreeString(bszSettingsC[0]); } else if (varStr == COleVariant(pName + " - Win32 Hybrid")) { pConfig->AddToolSettings(bszComp, bszSettingsC[1], var); SysFreeString(bszSettingsC[1]); } else // release { pConfig->AddToolSettings(bszComp, bszSettingsC[2], var); SysFreeString(bszSettingsC[2]); // For release config add "/release" flag to linker settings BSTR rel = CString(_T("/release")).AllocSysString(); pConfig->AddToolSettings(bszLink, rel, var); SysFreeString(rel); } pConfig->RemoveToolSettings(bszComp, bszRemSettingsC, var); pConfig->Release(); } SysFreeString(bszComp); SysFreeString(bszLink); SysFreeString(bszMfc); SysFreeString(bszRemSettingsC); SysFreeString(bszHyb); SysFreeString(bszSettingsL); SysFreeString(bszSettingsG); pConfigs->Release(); #if (1) //The following opens the Root.cpp document in the DevStudio IApplication *pApp; IDocuments *pDocs; IDocuments *pDoc; BSTR bszRoot = (pName + CString(_T(".cpp"))).AllocSysString(); COleVariant varOpenAs(CString(_T("Text"))); COleVariant varReadOnly(0L, VT_BOOL); pProject->get_Application((IDispatch **)&pApp); pApp->get_Documents((IDispatch **)&pDocs); pDocs->Open(bszRoot, varOpenAs, varReadOnly, (IDispatch **)&pDoc); SysFreeString(bszRoot); pApp->Release(); pDocs->Release(); pDoc->Release(); #endif }
//------------------------------------------------------------------------------------------- // This public member function opens file with the given name in the Developer Studio // and highlights the siven line. It also gives focus to the Developer Studio. //------------------------------------------------------------------------------------------- bool CCommands::MakeSelection(CString& file, int line, int col, int len) { ITextDocument* iDocument; IDocuments* iDocuments; ITextSelection* iSelection; // First, check if the given file exists. (Developer Studio will hang for a while // trying to open non-existing file). if(_access(file,04)==-1) return false; // Get document collection from the application object. if(m_pApplication->get_Documents((IDispatch **)&iDocuments)!=S_OK) return false; if(iDocuments==NULL) return false; // Open new document and add it to the documents collection (if not exists). VARIANT varType; varType.vt = VT_BSTR; varType.bstrVal=CString("Auto").AllocSysString(); VARIANT varReadonly; varReadonly.vt = VT_BOOL; varReadonly.boolVal = FALSE; if(iDocuments->Open(file.AllocSysString(),varType,varReadonly,(IDispatch **)&iDocument)!=S_OK) { iDocuments->Release(); return false; } // We do not need documents collection any more iDocuments->Release(); if(iDocument==NULL) return false; // Get text selection from the current document if(iDocument->get_Selection((IDispatch **)&iSelection)!=S_OK) return false; // We do not need document object any more. iDocument->Release(); if(iSelection==NULL) return false; // Move to the first position in the given line VARIANT selAct; selAct.vt = VT_INT; selAct.intVal = dsMove; iSelection->MoveTo(line,1,selAct); VARIANT repCount; repCount.vt = VT_INT; repCount.intVal = col-1; iSelection->CharRight(selAct, repCount); // Move to the end of this line in "Shift key pressed" mode. selAct.intVal = dsExtend; repCount.intVal = len; iSelection->CharRight(selAct, repCount); // We do not need text selection object any more iSelection->Release(); // Pop-up MSDEV application. m_pApplication->put_Active(VARIANT_TRUE); return true; }