Example #1
0
void CRTFReaderTHDDlg::ViewFile(CString sName)
{
	FILE* pFile = _tfopen(sName, _T("r"));
	bool bRTF = (fgetc(pFile) == '{');
	fclose(pFile);


	if (bRTF)
	{
		if (CGeneral::FileExists(_T("C:\\Program Files\\TextPad 4\\TextPad.exe")))
		{
			LaunchProc(_T("C:\\Program Files\\TextPad 4\\TextPad.exe"), sName);
			return;
		}
	}
	else
	{
		if (CGeneral::FileExists(_T("C:\\Program Files\\Schema Software Inc\\Vix\\Vix.exe")))
		{
			LaunchProc(_T("C:\\Program Files\\Schema Software Inc\\Vix\\Vix.exe"), sName);
			return;
		}
	}




	ShellExecute(m_hWnd, 0, sName, 0, _T("."), SW_SHOW);
}
void CPatchListCtrl::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
	int selected=this->GetSelectedCount();
	int index=0;
	POSITION pos=this->GetFirstSelectedItemPosition();
	index=this->GetNextSelectedItem(pos);

	CIconMenu popup;
	if (popup.CreatePopupMenu())
	{
		if(selected == 1)
		{
			if( m_ContextMenuMask&GetMenuMask(MENU_VIEWPATCH))
				popup.AppendMenuIcon(MENU_VIEWPATCH, IDS_MENU_VIEWPATCH, 0);

			if( m_ContextMenuMask&GetMenuMask(MENU_VIEWWITHMERGE))
				popup.AppendMenuIcon(MENU_VIEWWITHMERGE, IDS_MENU_VIEWWITHMERGE, 0);

			popup.SetDefaultItem(MENU_VIEWPATCH, FALSE);
		}
		if(selected >= 1)
		{
			if( m_ContextMenuMask&GetMenuMask(MENU_SENDMAIL))
				popup.AppendMenuIcon(MENU_SENDMAIL, IDS_MENU_SENDMAIL, IDI_MENUSENDMAIL);

			if( m_ContextMenuMask&GetMenuMask(MENU_APPLY))
				popup.AppendMenuIcon(MENU_APPLY, IDS_MENU_APPLY, 0);
		}

		int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);

		switch (cmd)
		{
		case MENU_VIEWPATCH:
			{

				CString path=GetItemText(index,0);
				CTGitPath gitpath;
				gitpath.SetFromWin(path);

				CAppUtils::StartUnifiedDiffViewer(path,gitpath.GetFilename());
				break;
			}
		case MENU_VIEWWITHMERGE:
			{
				CString path=GetItemText(index,0);
				CTGitPath gitpath;
				gitpath.SetFromWin(path);

				CTGitPath dir;
				dir.SetFromGit(g_Git.m_CurrentDir);

				CAppUtils::StartExtPatch(gitpath,dir);
				break;
			}
		case MENU_SENDMAIL:
			{
				LaunchProc(_T("sendmail"));
				break;
			}
		case MENU_APPLY:
			{
				LaunchProc(_T("importpatch"));

				break;
			}
		default:
			break;
		}
	}
}