HRESULT CWebBrowserUI::RegisterEventHandler( BOOL inAdvise ) { CComPtr<IWebBrowser2> pWebBrowser; CComPtr<IConnectionPointContainer> pCPC; CComPtr<IConnectionPoint> pCP; HRESULT hr = GetControl(IID_IWebBrowser2, (void**)&pWebBrowser); if (FAILED(hr)) return hr; hr=pWebBrowser->QueryInterface(IID_IConnectionPointContainer,(void **)&pCPC); if (FAILED(hr)) return hr; hr=pCPC->FindConnectionPoint(DIID_DWebBrowserEvents2,&pCP); if (FAILED(hr)) return hr; if (inAdvise) { hr = pCP->Advise((IDispatch*)this, &m_dwCookie); } else { hr = pCP->Unadvise(m_dwCookie); } return hr; }
HRESULT CPolyCommand::initialize() { HRESULT hr = S_OK; try { // Get an instance of a wrapper for a non-db-resident polygon if (FAILED(hr = m_pPoly.CoCreateInstance(CLSID_ComPolygon))) { // most likely problem, be a little more descriptive here acutPrintf("\nUnable to load ComPolygon"); throw hr; } // Get the base object - needed for those methods inherited by polygon m_pBaseObj = m_pPoly; m_pBaseObj->CreateObject(); // Get an instance of a listner so we know when input has been // entered in OPM if (FAILED(hr = CComObject<CComPolyCmd>::CreateInstance(&m_pPolyCmd))) throw hr; m_pPolyCmd->SetDocument(curDoc()); hr = m_pPolyCmd->QueryInterface(IID_IUnknown,(LPVOID *)&m_pUnkCmd); if (FAILED(hr)) throw hr; // Attach the listener to the polygon wrapper CComQIPtr<IConnectionPointContainer> pPtContainer; pPtContainer = m_pPoly; hr = pPtContainer->FindConnectionPoint( IID_IPropertyNotifySink,&m_pConPt); if (FAILED(hr)) throw hr; if (FAILED(hr = m_pConPt->Advise(m_pUnkCmd,&m_dConnectionID))) throw hr; acedSetIUnknownForCurrentCommand(m_pPoly); m_pDb = curDoc()->database(); setDefaults(); } catch (HRESULT) { fail(); } return hr; }
bool IEDebugger::advise(IDebugApplicationNode* node, bool isRoot, bool recurse) { CComPtr<IConnectionPointContainer> connectionPointContainer = NULL; HRESULT hr = node->QueryInterface(IID_IConnectionPointContainer, (void**)&connectionPointContainer); if (FAILED(hr)) { Logger::error("IEDebugger.advise(): QI(IID_IConnectionPointContainer) failed", hr); return false; } CComPtr<IConnectionPoint> nodeConnectionPoint = NULL; hr = connectionPointContainer->FindConnectionPoint(IID_IDebugApplicationNodeEvents, &nodeConnectionPoint); if (FAILED(hr)) { Logger::error("IEDebugger.advise(): FindConnectionPoint() failed", hr); return false; } DWORD connectionPointCookie = 0; hr = nodeConnectionPoint->Advise(static_cast<IIEDebugger*>(this), &connectionPointCookie); if (FAILED(hr)) { Logger::error("IEDebugger.advise(): Advise() failed", hr); return false; } if (isRoot) { m_rootCookie = connectionPointCookie; m_rootNode = node; } else { m_adviseCookies->insert(std::pair<IDebugApplicationNode*,DWORD>(node, connectionPointCookie)); } node->AddRef(); if (recurse) { CComPtr<IEnumDebugApplicationNodes> nodes = NULL; hr = node->EnumChildren(&nodes); if (FAILED(hr)) { Logger::error("IEDebugger.advise(): EnumChildren() failed", hr); } else { IDebugApplicationNode* current = NULL; ULONG count = 0; hr = nodes->Next(1, ¤t, &count); while (SUCCEEDED(hr) && count) { advise(current, false, true); current->Release(); hr = nodes->Next(1, ¤t, &count); } } } return true; }
HRESULT CBhoApp::Connect() { HRESULT hr; CComPtr<IConnectionPoint> spCP; // Receives the connection point for WebBrowser events hr = m_spCPC->FindConnectionPoint(DIID_DWebBrowserEvents2, &spCP); if (FAILED(hr)) return hr; // Pass our event handlers to the container. Each time an event occurs // the container will invoke the functions of the IDispatch interface // we implemented. hr = spCP->Advise(reinterpret_cast<IDispatch*>(this),&m_dwCookie); return hr; }
HRESULT Cdlext::RegisterEventHandler(BOOL inAdvise) { CComPtr<IConnectionPoint> spCP; // Receives the connection point for WebBrowser events CComQIPtr<IConnectionPointContainer,&IID_IConnectionPointContainer> spCPC(mWebBrowser2); HRESULT hr = spCPC->FindConnectionPoint(DIID_DWebBrowserEvents2, &spCP); if (FAILED(hr)) return hr; if(inAdvise) { //hr=spCP->Advise(reinterpret_cast(this),&mCookie); hr = spCP->Advise((IDispatch*)this, &mCookie); } else { spCP->Unadvise(mCookie); } return hr; }
void IISxpressAPI::ResponseHistory::AttachConnectionPoint() { m_dwCookie = 0; m_pHTTPNotifyCP = nullptr; if (m_pNotifyObj == nullptr) { // TODO: a better error message here throw gcnew System::Exception(); } CComPtr<IIISxpressHTTPRequest> pHTTPRequest; HRESULT hr = GetHTTPRequest(&pHTTPRequest); if (hr != S_OK) { throw gcnew IISxpressAPI::IISxpressAPIException(hr); } CComQIPtr<IConnectionPointContainer> pConnPointCont = pHTTPRequest; if (pConnPointCont != NULL) { if (pConnPointCont != NULL) { CComPtr<IConnectionPoint> pHTTPNotifyCP; HRESULT hr = pConnPointCont->FindConnectionPoint(IID_IIISxpressHTTPNotify, &pHTTPNotifyCP); if (pHTTPNotifyCP != NULL) { CComPtr<IUnknown> pUnk; m_pNotifyObj->QueryInterface(IID_IUnknown, (void**) &pUnk); DWORD dwCookie = 0; hr = pHTTPNotifyCP->Advise(pUnk, &dwCookie); m_pHTTPNotifyCP = pHTTPNotifyCP.Detach(); m_dwCookie = dwCookie; } } } }
/////////////////////////////////////////////////////////////////////////// // Connect/Disconnect to the DWebBrowserEvents2 Source /////////////////////////////////////////////////////////////////////////// bool CHtmlWindowEventSink::advise(IHTMLWindow2 *pHtmlWindow) { HRESULT hr; if (!pHtmlWindow) return false; m_spHtmlWindow=pHtmlWindow; CComQIPtr<IConnectionPointContainer, &IID_IConnectionPointContainer> spCPContainer=m_spHtmlWindow; if (spCPContainer != NULL) { CComPtr<IConnectionPoint> spConnectionPoint; hr = spCPContainer->FindConnectionPoint(DIID_HTMLWindowEvents2, &spConnectionPoint); if (SUCCEEDED(hr) && !m_dwCookie) { hr = spConnectionPoint->Advise((IDispatch*)this, &m_dwCookie); if (FAILED(hr)) ATLTRACE("CWebBrowserEventSink: advise(): Failed\n\n"); } return SUCCEEDED(hr); } return false; }
CBrowseFolder::retVal CBrowseFolder::Show(HWND parent, CString& path, const CString& sDefaultPath /* = CString() */) { m_sDefaultPath = sDefaultPath; if (m_sDefaultPath.IsEmpty() && !path.IsEmpty()) { while (!PathFileExists(path) && !path.IsEmpty()) { CString p = path.Left(path.ReverseFind(L'\\')); if ((p.GetLength() == 2) && (p[1] == L':')) { p += L"\\"; if (p.Compare(path) == 0) p.Empty(); } if (p.GetLength() < 2) p.Empty(); path = p; } // if the result path already contains a path, use that as the default path m_sDefaultPath = path; } // Create a new common open file dialog CComPtr<IFileOpenDialog> pfd; if (FAILED(pfd.CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC_SERVER))) return CANCEL; // Set the dialog as a folder picker DWORD dwOptions; if (FAILED(pfd->GetOptions(&dwOptions))) return CANCEL; if (FAILED(pfd->SetOptions(dwOptions | FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST))) return CANCEL; // Set a title TCHAR* nl = _tcschr(m_title, '\n'); if (nl) *nl = 0; pfd->SetTitle(m_title); // set the default folder CComPtr<IShellItem> psiDefault; if (FAILED(SHCreateItemFromParsingName(m_sDefaultPath, nullptr, IID_PPV_ARGS(&psiDefault)))) return CANCEL; if (FAILED(pfd->SetFolder(psiDefault))) return CANCEL; CComObjectStackEx<BrowseFolderDlgEventHandler> cbk; cbk.m_DisableCheckbox2WhenCheckbox1IsChecked = m_DisableCheckbox2WhenCheckbox1IsChecked; CComQIPtr<IFileDialogEvents> pEvents = cbk.GetUnknown(); if (!m_CheckText.IsEmpty()) { CComPtr<IFileDialogCustomize> pfdCustomize; if (FAILED(pfd.QueryInterface(&pfdCustomize))) return CANCEL; pfdCustomize->StartVisualGroup(100, L""); pfdCustomize->AddCheckButton(101, m_CheckText, FALSE); if (!m_CheckText2.IsEmpty()) pfdCustomize->AddCheckButton(102, m_CheckText2, FALSE); pfdCustomize->EndVisualGroup(); } DWORD eventsCookie; if (FAILED(pfd->Advise(pEvents, &eventsCookie))) return CANCEL; SCOPE_EXIT { pfd->Unadvise(eventsCookie); }; // Show the open file dialog if (FAILED(pfd->Show(parent))) return CANCEL; // Get the selection from the user CComPtr<IShellItem> psiResult; if (FAILED(pfd->GetResult(&psiResult))) return CANCEL; PWSTR pszPath = nullptr; if (SUCCEEDED(psiResult->GetDisplayName(SIGDN_FILESYSPATH, &pszPath))) { path = pszPath; CoTaskMemFree(pszPath); } CComPtr<IFileDialogCustomize> pfdCustomize; if (SUCCEEDED(pfd.QueryInterface(&pfdCustomize))) { pfdCustomize->GetCheckButtonState(101, &m_bCheck); pfdCustomize->GetCheckButtonState(102, &m_bCheck2); } return OK; }
// CTortoiseMergeApp initialization BOOL CTortoiseMergeApp::InitInstance() { SetDllDirectory(L""); SetTaskIDPerUUID(); CCrashReport::Instance().AddUserInfoToReport(L"CommandLine", GetCommandLine()); { DWORD len = GetCurrentDirectory(0, NULL); if (len) { std::unique_ptr<TCHAR[]> originalCurrentDirectory(new TCHAR[len]); if (GetCurrentDirectory(len, originalCurrentDirectory.get())) { sOrigCWD = originalCurrentDirectory.get(); sOrigCWD = CPathUtils::GetLongPathname(sOrigCWD); } } } //set the resource dll for the required language CRegDWORD loc = CRegDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033); long langId = loc; CString langDll; HINSTANCE hInst = NULL; do { langDll.Format(_T("%sLanguages\\TortoiseMerge%ld.dll"), (LPCTSTR)CPathUtils::GetAppParentDirectory(), langId); hInst = LoadLibrary(langDll); CString sVer = _T(STRPRODUCTVER); CString sFileVer = CPathUtils::GetVersionFromFile(langDll); if (sFileVer.Compare(sVer)!=0) { FreeLibrary(hInst); hInst = NULL; } if (hInst != NULL) AfxSetResourceHandle(hInst); else { DWORD lid = SUBLANGID(langId); lid--; if (lid > 0) { langId = MAKELANGID(PRIMARYLANGID(langId), lid); } else langId = 0; } } while ((hInst == NULL) && (langId != 0)); TCHAR buf[6] = { 0 }; _tcscpy_s(buf, _T("en")); langId = loc; CString sHelppath = CPathUtils::GetAppDirectory() + _T("TortoiseMerge_en.chm"); free((void*)m_pszHelpFilePath); m_pszHelpFilePath=_tcsdup(sHelppath); sHelppath = CPathUtils::GetAppParentDirectory() + _T("Languages\\TortoiseMerge_en.chm"); do { GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO639LANGNAME, buf, _countof(buf)); CString sLang = _T("_"); sLang += buf; sHelppath.Replace(_T("_en"), sLang); if (PathFileExists(sHelppath)) { free((void*)m_pszHelpFilePath); m_pszHelpFilePath=_tcsdup(sHelppath); break; } sHelppath.Replace(sLang, _T("_en")); GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO3166CTRYNAME, buf, _countof(buf)); sLang += _T("_"); sLang += buf; sHelppath.Replace(_T("_en"), sLang); if (PathFileExists(sHelppath)) { free((void*)m_pszHelpFilePath); m_pszHelpFilePath=_tcsdup(sHelppath); break; } sHelppath.Replace(sLang, _T("_en")); DWORD lid = SUBLANGID(langId); lid--; if (lid > 0) { langId = MAKELANGID(PRIMARYLANGID(langId), lid); } else langId = 0; } while (langId); setlocale(LC_ALL, ""); // We need to explicitly set the thread locale to the system default one to avoid possible problems with saving files in its original codepage // The problems occures when the language of OS differs from the regional settings // See the details here: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100887 SetThreadLocale(LOCALE_SYSTEM_DEFAULT); // InitCommonControls() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. InitCommonControls(); CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); CMFCButton::EnableWindowsTheming(); EnableTaskbarInteraction(FALSE); // Initialize all Managers for usage. They are automatically constructed // if not yet present InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager (); CMFCToolTipInfo params; params.m_bVislManagerTheme = TRUE; GetTooltipManager ()->SetTooltipParams ( AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS (CMFCToolTipCtrl), ¶ms); CCmdLineParser parser = CCmdLineParser(this->m_lpCmdLine); g_sGroupingUUID = parser.GetVal(L"groupuuid"); if (parser.HasKey(_T("?")) || parser.HasKey(_T("help"))) { CString sHelpText; sHelpText.LoadString(IDS_COMMANDLINEHELP); MessageBox(NULL, sHelpText, _T("TortoiseGitMerge"), MB_ICONINFORMATION); return FALSE; } // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_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 // Change the registry key under which our settings are stored SetRegistryKey(_T("TortoiseGitMerge")); if (CRegDWORD(_T("Software\\TortoiseGitMerge\\Debug"), FALSE)==TRUE) AfxMessageBox(AfxGetApp()->m_lpCmdLine, MB_OK | MB_ICONINFORMATION); // To create the main window, this code creates a new frame window // object and then sets it as the application's main window object CMainFrame* pFrame = new CMainFrame; if (pFrame == NULL) return FALSE; m_pMainWnd = pFrame; // create and load the frame with its resources if (!pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL)) return FALSE; // Fill in the command line options pFrame->m_Data.m_baseFile.SetFileName(parser.GetVal(_T("base"))); pFrame->m_Data.m_baseFile.SetDescriptiveName(parser.GetVal(_T("basename"))); pFrame->m_Data.m_baseFile.SetReflectedName(parser.GetVal(_T("basereflectedname"))); pFrame->m_Data.m_theirFile.SetFileName(parser.GetVal(_T("theirs"))); pFrame->m_Data.m_theirFile.SetDescriptiveName(parser.GetVal(_T("theirsname"))); pFrame->m_Data.m_theirFile.SetReflectedName(parser.GetVal(_T("theirsreflectedname"))); pFrame->m_Data.m_yourFile.SetFileName(parser.GetVal(_T("mine"))); pFrame->m_Data.m_yourFile.SetDescriptiveName(parser.GetVal(_T("minename"))); pFrame->m_Data.m_yourFile.SetReflectedName(parser.GetVal(_T("minereflectedname"))); pFrame->m_Data.m_mergedFile.SetFileName(parser.GetVal(_T("merged"))); pFrame->m_Data.m_mergedFile.SetDescriptiveName(parser.GetVal(_T("mergedname"))); pFrame->m_Data.m_mergedFile.SetReflectedName(parser.GetVal(_T("mergedreflectedname"))); pFrame->m_Data.m_sPatchPath = parser.HasVal(_T("patchpath")) ? parser.GetVal(_T("patchpath")) : _T(""); pFrame->m_Data.m_sPatchPath.Replace('/', '\\'); if (parser.HasKey(_T("patchoriginal"))) pFrame->m_Data.m_sPatchOriginal = parser.GetVal(_T("patchoriginal")); if (parser.HasKey(_T("patchpatched"))) pFrame->m_Data.m_sPatchPatched = parser.GetVal(_T("patchpatched")); pFrame->m_Data.m_sDiffFile = parser.GetVal(_T("diff")); pFrame->m_Data.m_sDiffFile.Replace('/', '\\'); if (parser.HasKey(_T("oneway"))) pFrame->m_bOneWay = TRUE; if (parser.HasKey(_T("diff"))) pFrame->m_bOneWay = FALSE; if (parser.HasKey(_T("reversedpatch"))) pFrame->m_bReversedPatch = TRUE; if (parser.HasKey(_T("saverequired"))) pFrame->m_bSaveRequired = true; if (parser.HasKey(_T("saverequiredonconflicts"))) pFrame->m_bSaveRequiredOnConflicts = true; if (parser.HasKey(_T("deletebasetheirsmineonclose"))) pFrame->m_bDeleteBaseTheirsMineOnClose = true; if (pFrame->m_Data.IsBaseFileInUse() && !pFrame->m_Data.IsYourFileInUse() && pFrame->m_Data.IsTheirFileInUse()) { pFrame->m_Data.m_yourFile.TransferDetailsFrom(pFrame->m_Data.m_theirFile); } if ((!parser.HasKey(_T("patchpath")))&&(parser.HasVal(_T("diff")))) { // a patchfile was given, but not folder path to apply the patch to // If the patchfile is located inside a working copy, then use the parent directory // of the patchfile as the target directory, otherwise ask the user for a path. if (parser.HasKey(_T("wc"))) pFrame->m_Data.m_sPatchPath = pFrame->m_Data.m_sDiffFile.Left(pFrame->m_Data.m_sDiffFile.ReverseFind('\\')); else { CBrowseFolder fbrowser; fbrowser.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; if (fbrowser.Show(NULL, pFrame->m_Data.m_sPatchPath)==CBrowseFolder::CANCEL) return FALSE; } } if ((parser.HasKey(_T("patchpath")))&&(!parser.HasVal(_T("diff")))) { // A path was given for applying a patchfile, but // the patchfile itself was not. // So ask the user for that patchfile HRESULT hr; // Create a new common save file dialog CComPtr<IFileOpenDialog> pfd = NULL; hr = pfd.CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER); if (SUCCEEDED(hr)) { // Set the dialog options DWORD dwOptions; if (SUCCEEDED(hr = pfd->GetOptions(&dwOptions))) { hr = pfd->SetOptions(dwOptions | FOS_FILEMUSTEXIST | FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST); } // Set a title if (SUCCEEDED(hr)) { CString temp; temp.LoadString(IDS_OPENDIFFFILETITLE); pfd->SetTitle(temp); } CSelectFileFilter fileFilter(IDS_PATCHFILEFILTER); hr = pfd->SetFileTypes(fileFilter.GetCount(), fileFilter); bool bAdvised = false; DWORD dwCookie = 0; CComObjectStackEx<PatchOpenDlgEventHandler> cbk; CComQIPtr<IFileDialogEvents> pEvents = cbk.GetUnknown(); { CComPtr<IFileDialogCustomize> pfdCustomize; hr = pfd->QueryInterface(IID_PPV_ARGS(&pfdCustomize)); if (SUCCEEDED(hr)) { // check if there's a unified diff on the clipboard and // add a button to the fileopen dialog if there is. UINT cFormat = RegisterClipboardFormat(_T("TSVN_UNIFIEDDIFF")); if ((cFormat)&&(OpenClipboard(NULL))) { HGLOBAL hglb = GetClipboardData(cFormat); if (hglb) { pfdCustomize->AddPushButton(101, CString(MAKEINTRESOURCE(IDS_PATCH_COPYFROMCLIPBOARD))); hr = pfd->Advise(pEvents, &dwCookie); bAdvised = SUCCEEDED(hr); } CloseClipboard(); } } } // Show the save file dialog if (SUCCEEDED(hr) && SUCCEEDED(hr = pfd->Show(pFrame->m_hWnd))) { // Get the selection from the user CComPtr<IShellItem> psiResult = NULL; hr = pfd->GetResult(&psiResult); if (bAdvised) pfd->Unadvise(dwCookie); if (SUCCEEDED(hr)) { PWSTR pszPath = NULL; hr = psiResult->GetDisplayName(SIGDN_FILESYSPATH, &pszPath); if (SUCCEEDED(hr)) { pFrame->m_Data.m_sDiffFile = pszPath; CoTaskMemFree(pszPath); } } else { // no result, which means we closed the dialog in our button handler std::wstring sTempFile; if (TrySavePatchFromClipboard(sTempFile)) pFrame->m_Data.m_sDiffFile = sTempFile.c_str(); } } else { if (bAdvised) pfd->Unadvise(dwCookie); return FALSE; } } else { OPENFILENAME ofn = {0}; // common dialog box structure TCHAR szFile[MAX_PATH] = {0}; // buffer for file name // Initialize OPENFILENAME ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = pFrame->m_hWnd; ofn.lpstrFile = szFile; ofn.nMaxFile = _countof(szFile); CString temp; temp.LoadString(IDS_OPENDIFFFILETITLE); if (temp.IsEmpty()) ofn.lpstrTitle = NULL; else ofn.lpstrTitle = temp; ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER; if( HasClipboardPatch() ) { ofn.Flags |= ( OFN_ENABLETEMPLATE | OFN_ENABLEHOOK ); ofn.hInstance = AfxGetResourceHandle(); ofn.lpTemplateName = MAKEINTRESOURCE(IDD_PATCH_FILE_OPEN_CUSTOM); ofn.lpfnHook = CreatePatchFileOpenHook; } CSelectFileFilter fileFilter(IDS_PATCHFILEFILTER); ofn.lpstrFilter = fileFilter; ofn.nFilterIndex = 1; // Display the Open dialog box. if (GetOpenFileName(&ofn)==FALSE) { return FALSE; } pFrame->m_Data.m_sDiffFile = ofn.lpstrFile; } } if ( pFrame->m_Data.m_baseFile.GetFilename().IsEmpty() && pFrame->m_Data.m_yourFile.GetFilename().IsEmpty() ) { int nArgs; LPWSTR *szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); if( NULL == szArglist ) { TRACE("CommandLineToArgvW failed\n"); } else { if ( nArgs==3 || nArgs==4 ) { // Four parameters: // [0]: Program name // [1]: BASE file // [2]: my file // [3]: THEIR file (optional) // This is the same format CAppUtils::StartExtDiff // uses if %base and %mine are not set and most // other diff tools use it too. if ( PathFileExists(szArglist[1]) && PathFileExists(szArglist[2]) ) { pFrame->m_Data.m_baseFile.SetFileName(szArglist[1]); pFrame->m_Data.m_yourFile.SetFileName(szArglist[2]); if ( nArgs == 4 && PathFileExists(szArglist[3]) ) { pFrame->m_Data.m_theirFile.SetFileName(szArglist[3]); } } } else if (nArgs == 2) { // only one path specified: use it to fill the "open" dialog if (PathFileExists(szArglist[1])) { pFrame->m_Data.m_yourFile.SetFileName(szArglist[1]); pFrame->m_Data.m_yourFile.StoreFileAttributes(); } } } // Free memory allocated for CommandLineToArgvW arguments. LocalFree(szArglist); } pFrame->m_bReadOnly = !!parser.HasKey(_T("readonly")); if (GetFileAttributes(pFrame->m_Data.m_yourFile.GetFilename()) & FILE_ATTRIBUTE_READONLY) pFrame->m_bReadOnly = true; pFrame->m_bBlame = !!parser.HasKey(_T("blame")); // diffing a blame means no editing! if (pFrame->m_bBlame) pFrame->m_bReadOnly = true; pFrame->SetWindowTitle(); if (parser.HasKey(_T("createunifieddiff"))) { // user requested to create a unified diff file CString origFile = parser.GetVal(_T("origfile")); CString modifiedFile = parser.GetVal(_T("modifiedfile")); if (!origFile.IsEmpty() && !modifiedFile.IsEmpty()) { CString outfile = parser.GetVal(_T("outfile")); if (outfile.IsEmpty()) { CCommonAppUtils::FileOpenSave(outfile, NULL, IDS_SAVEASTITLE, IDS_COMMONFILEFILTER, false, NULL); } if (!outfile.IsEmpty()) { CRegStdDWORD regContextLines(L"Software\\TortoiseGitMerge\\ContextLines", (DWORD)-1); CAppUtils::CreateUnifiedDiff(origFile, modifiedFile, outfile, regContextLines, false); return FALSE; } } } pFrame->resolveMsgWnd = parser.HasVal(L"resolvemsghwnd") ? (HWND)parser.GetLongLongVal(L"resolvemsghwnd") : 0; pFrame->resolveMsgWParam = parser.HasVal(L"resolvemsgwparam") ? (WPARAM)parser.GetLongLongVal(L"resolvemsgwparam") : 0; pFrame->resolveMsgLParam = parser.HasVal(L"resolvemsglparam") ? (LPARAM)parser.GetLongLongVal(L"resolvemsglparam") : 0; // The one and only window has been initialized, so show and update it pFrame->ActivateFrame(); pFrame->ShowWindow(SW_SHOW); pFrame->UpdateWindow(); pFrame->ShowDiffBar(!pFrame->m_bOneWay); if (!pFrame->m_Data.IsBaseFileInUse() && pFrame->m_Data.m_sPatchPath.IsEmpty() && pFrame->m_Data.m_sDiffFile.IsEmpty()) { pFrame->OnFileOpen(pFrame->m_Data.m_yourFile.InUse()); return TRUE; } int line = -2; if (parser.HasVal(_T("line"))) { line = parser.GetLongVal(_T("line")); line--; // we need the index } return pFrame->LoadViews(line); }