Example #1
0
bool EditFind::ReplaceAll(void)
{
  ASSERT(m_findOnly == false);

  // Does the current selection match?
  bool currentMatch = false;
  {
    CHARRANGE sel = m_edit->GetSelect();
    CStringW selText = m_edit->GetTextRange(sel.cpMin,sel.cpMax);

    if (m_dialog->MatchCase())
    {
      if (selText.Compare(m_dialog->GetFindString()) == 0)
        currentMatch = true;
    }
    else
    {
      if (selText.CompareNoCase(m_dialog->GetFindString()) == 0)
        currentMatch = true;
    }
  }

  if (currentMatch || FindNext(true))
  {
    while (Replace());
    return true;
  }
  return false;
}
// detect the version of CLR
BOOL DetermineDotNetVersion(void)
{
	WCHAR wszPath[MAX_PATH] = {0};
	::GetModuleFileNameW( g_hClrModule, wszPath, MAX_PATH);
	CStringW strPath(wszPath);
	int nIndex = strPath.ReverseFind('\\');
	if( nIndex <= 0 )
		return FALSE;
	nIndex++;
	CStringW strFilename = strPath.Mid( nIndex, strPath.GetLength() - nIndex);
	if( strFilename.CompareNoCase(L"mscorwks.dll") == 0 )
	{
		g_tDotNetVersion = DotNetVersion_20;
		return TRUE;
	}

	if( strFilename.CompareNoCase(L"clr.dll") == 0 )
	{
		VS_FIXEDFILEINFO tVerInfo = {0};
		if ( CUtility::GetFileVersion( wszPath, &tVerInfo) &&
			 tVerInfo.dwSignature == 0xfeef04bd)
		{
			int nMajor = HIWORD(tVerInfo.dwFileVersionMS);
			int nMinor = LOWORD(tVerInfo.dwFileVersionMS);
			int nBuildMajor = HIWORD(tVerInfo.dwFileVersionLS);
			int nBuildMinor = LOWORD(tVerInfo.dwFileVersionLS);

			if( nMajor == 4 && nMinor == 0 && nBuildMajor == 30319 )
			{
				if( nBuildMinor < 10000 )
					g_tDotNetVersion = DotNetVersion_40;
				else
					g_tDotNetVersion = DotNetVersion_45;
				return TRUE;
			}
		}
		return FALSE;
	}

	return FALSE;
}
bool CURLList::ReadData(const TiXmlNode *pUrlList)
{
	m_WebsiteData.clear();
	WebsiteType eWebsiteType;
	std::string strType = pUrlList->ToElement()->Attribute("name");
	if (strType == "banks")
		eWebsiteType = Website_Bank;
	else
		ATLASSERT(0);

	for (const TiXmlNode *pSite = pUrlList->FirstChild("site"); pSite != NULL; pSite = pUrlList->IterateChildren("site", pSite))
	{
		CWebsiteData *pWebsiteData = new CWebsiteData;
		pWebsiteData->m_strID = AToW(pSite->ToElement()->Attribute("id"));
		pWebsiteData->m_strName = AToW(pSite->ToElement()->Attribute("name"));

		pWebsiteData->m_bNoClose = false;
		if (pSite->ToElement()->Attribute("noclose") != NULL)
		{
			CStringW strNoClose = AToW(pSite->ToElement()->Attribute("noclose")).c_str();
			strNoClose.Trim();
			if (strNoClose.CompareNoCase(L"true") == 0)
				pWebsiteData->m_bNoClose = true;
		}

		pWebsiteData->m_eWebsiteType = eWebsiteType;
		const TiXmlNode *pDomainList = pSite->FirstChild("domains");
		if (pDomainList)
		{

			for (const TiXmlNode *pDomain = pDomainList->FirstChild("domain"); pDomain != NULL; pDomain = pDomainList->IterateChildren("domain", pDomain))
			{
				std::wstring strDomain = AToW(pDomain->ToElement()->Attribute("name"));

				WebDataMap::iterator it = m_WebsiteData.find (strDomain);
				if (it == m_WebsiteData.end()) // 如果不存在
				{						
					m_WebsiteData.insert(std::make_pair(strDomain, pWebsiteData)); // 插入
				}

			}

		}
		else
		{
			delete pWebsiteData;
			pWebsiteData = NULL;
		}

	}
	return true;
}
Example #4
0
void CHelperDlg::BeforeNavigate2ExplorerHelper(LPDISPATCH pDisp, VARIANT* URL, VARIANT* Flags, VARIANT* TargetFrameName, VARIANT* PostData, VARIANT* Headers, BOOL* Cancel)
{
	CStringW strURLIn(URL->bstrVal);
	CStringW strProtol = strURLIn.Mid(0, 7);
	if(strProtol.CompareNoCase(L"anch://")==0)
	{
		*Cancel = TRUE;
		CString strAnchor = CString(strURLIn.Mid(7));
		strAnchor.TrimRight(L"/\\");

		char szAnchor[MAX_PATH]={0};
		::WideCharToMultiByte(CP_ACP, 0, strAnchor, strAnchor.GetLength(), szAnchor, MAX_PATH, 0, 0);
		CHelperSystem::GetMe()->GotoAnchor(szAnchor);
	}
}
  bool IsDefaultBrowser()
  {
    IApplicationAssociationRegistration* pAAR;
    HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
                                  nullptr,
                                  CLSCTX_INPROC,
                                  IID_IApplicationAssociationRegistration,
                                  (void**)&pAAR);
    if (FAILED(hr))
      return false;

    BOOL res = FALSE;
    hr = pAAR->QueryAppIsDefaultAll(AL_EFFECTIVE,
                                    APP_REG_NAME,
                                    &res);
    Log(L"QueryAppIsDefaultAll: %d", res);
    if (!res) {
      pAAR->Release();
      return false;
    }
    // Make sure the Prog ID matches what we have
    LPWSTR registeredApp;
    hr = pAAR->QueryCurrentDefault(L"http", AT_URLPROTOCOL, AL_EFFECTIVE,
                                    &registeredApp);
    pAAR->Release();
    Log(L"QueryCurrentDefault: %X", hr);
    if (FAILED(hr))
      return false;

    Log(L"registeredApp=%s", registeredApp);
    bool result = !wcsicmp(registeredApp, kDefaultMetroBrowserIDPathKey);
    CoTaskMemFree(registeredApp);
    if (!result)
      return false;

    // If the registry points another browser's path,
    // activating the Metro browser will fail. So fallback to the desktop.
    CStringW selfPath;
    GetDesktopBrowserPath(selfPath);
    CStringW browserPath;
    GetDefaultBrowserPath(browserPath);

    return !selfPath.CompareNoCase(browserPath);
  }
Example #6
0
bool EditFind::Replace(void)
{
  ASSERT(m_findOnly == false);

  // Get the text in the current selection
  CHARRANGE sel = m_edit->GetSelect();
  CStringW selText = m_edit->GetTextRange(sel.cpMin,sel.cpMax);

  // If the current selection matches the text in the dialog, replace it
  if (m_dialog->MatchCase())
  {
    if (selText.Compare(m_dialog->GetFindString()) == 0)
      m_edit->ReplaceSelect(m_dialog->GetReplaceString());
  }
  else
  {
    if (selText.CompareNoCase(m_dialog->GetFindString()) == 0)
      m_edit->ReplaceSelect(m_dialog->GetReplaceString());
  }

  // Find the next occurence
  return FindNext(true);
}
Example #7
0
CLSID BitmapUtil::FindCodecForExtension( LPCTSTR pszExtension, const Gdiplus::ImageCodecInfo* pCodecs, UINT nCodecs )
{
	CT2CW pszExtensionW( pszExtension );

	for( UINT iCodec = 0; iCodec < nCodecs; iCodec++ )
	{
		CStringW strExtensions( pCodecs[iCodec].FilenameExtension );

		int iStart = 0;
		do
		{
			CStringW strExtension = ::PathFindExtensionW( strExtensions.Tokenize( L";", iStart ) );
			if( iStart != -1 )
			{
				if( strExtension.CompareNoCase( pszExtensionW ) == 0 )
				{
					return( pCodecs[iCodec].Clsid );
				}
			}
		} while( iStart != -1 );
	}

	return( CLSID_NULL );
}
Example #8
0
// Check if file name has a supported image type extension.
bool CMyStatic::IsSupportedFileExtension(LPCTSTR lpszFileName) const
{
	bool bIsSupportedFileExtension = false;
	LPCTSTR lpszExt = ::PathFindExtension(lpszFileName);
	if (_T('.') == *lpszExt)
	{
#if 1
		++lpszExt;
		static LPCTSTR lpszExtensions[] = { 
			_T("bmp"), _T("dib"), _T("rle"), 
			_T("jpg"), _T("jpeg"), _T("jpe"), _T("jfif"), 
			_T("gif"), 
			_T("tif"), _T("tiff"), 
			_T("png"), 
			_T("ico") 
		};
		int i = 0;
		while (!bIsSupportedFileExtension && lpszExtensions[i])
		{
			if (0 == _tcsicmp(lpszExt, lpszExtensions[i]))
				bIsSupportedFileExtension = true;
			++i;
		}
#else
		// Check file name extension against those of supported GDI+ codecs.
		// Based on code form atlimage.h.
		// Note that this check does not include .ico files which are supported for loading.
		ULONG_PTR gdiplusToken;
		Gdiplus::GdiplusStartupInput input;
		if (Gdiplus::Ok == Gdiplus::GdiplusStartup(&gdiplusToken, &input, NULL))
		{
			UINT nEncoders;
			UINT nBytes;
			if (Gdiplus::Ok == Gdiplus::GetImageEncodersSize(&nEncoders, &nBytes))
			{
				LPBYTE pBuf = new BYTE[nBytes];
				Gdiplus::ImageCodecInfo* pEncoders = reinterpret_cast<Gdiplus::ImageCodecInfo*>(pBuf);
				if (Gdiplus::Ok == Gdiplus::GetImageEncoders(nEncoders, nBytes, pEncoders))
				{
					CStringW strExtW(lpszExt);
					for (UINT iCodec = 0; iCodec < nEncoders && !bIsSupportedFileExtension; iCodec++)
					{
						CStringW strExtensions(pEncoders[iCodec].FilenameExtension);
						int iStart = 0;
						do
						{
							CStringW strExtension = ::PathFindExtensionW(strExtensions.Tokenize(L";", iStart));
							if (iStart != -1 &&
								0 == strExtension.CompareNoCase(strExtW.GetString()))
							{
								bIsSupportedFileExtension = true;
							}
						} while (iStart != -1 && !bIsSupportedFileExtension);
					}
				}
				delete [] pBuf;
			}
			Gdiplus::GdiplusShutdown(gdiplusToken);
		}
#endif
	}
	return bIsSupportedFileExtension;
}
bool CURLList::ReadData(const TiXmlNode *pUrlList)
{
	m_WebsiteData.clear();
	WebsiteType eWebsiteType;
	std::string strType = pUrlList->ToElement()->Attribute("name");
	if (strType == "banks")
		eWebsiteType = Website_Bank;
	else
		ATLASSERT(0);

	for (const TiXmlNode *pSite = pUrlList->FirstChild("site"); pSite != NULL; pSite = pUrlList->IterateChildren("site", pSite))
	{
		CWebsiteData *pWebsiteData = new CWebsiteData;
		pWebsiteData->m_strID = AToW(pSite->ToElement()->Attribute("id"));
		WebDataMap::iterator it = m_WebsiteData.find (pWebsiteData->m_strID);
		if (it == m_WebsiteData.end()) // 如果不存在
		{
			pWebsiteData->m_strName = AToW(pSite->ToElement()->Attribute("name"));

			pWebsiteData->m_bNoClose = false;
			if (pSite->ToElement()->Attribute("noclose") != NULL)
			{
				CStringW strNoClose = AToW(pSite->ToElement()->Attribute("noclose")).c_str();
				strNoClose.Trim();
				if (strNoClose.CompareNoCase(L"true") == 0)
					pWebsiteData->m_bNoClose = true;
			}

			pWebsiteData->m_bHasSubTab = false;
			pWebsiteData->m_bOnlyOneSubTab = false;
			if (pSite->ToElement()->Attribute("subTabNum") != NULL)
			{
				CStringW strNoSubTab = AToW(pSite->ToElement()->Attribute("subTabNum")).c_str();
				strNoSubTab.Trim();
				if (strNoSubTab.CompareNoCase(L"0") == 0)
					pWebsiteData->m_bHasSubTab = true;
				else if (strNoSubTab.CompareNoCase(L"1") == 0)
					pWebsiteData->m_bOnlyOneSubTab = true;
			}

			pWebsiteData->m_eWebsiteType = eWebsiteType;
			const TiXmlNode *pDomainList = pSite->FirstChild("domains");
			if (pDomainList)
			{
				for (const TiXmlNode *pDomain = pDomainList->FirstChild("domain"); pDomain != NULL; pDomain = pDomainList->IterateChildren("domain", pDomain))
				{
					std::wstring strDomain = AToW(pDomain->ToElement()->Attribute("name"));
					pWebsiteData->m_urllist.push_back(strDomain);
				}
				m_WebsiteData.insert(std::make_pair(pWebsiteData->m_strID, pWebsiteData));
			}
			else
			{
				delete pWebsiteData;
				pWebsiteData = NULL;
			}
		}
		else
		{			
			MessageBox(NULL, pWebsiteData->m_strID.c_str(), L"Info配置文件ID重复", MB_OK);
			delete pWebsiteData;
			pWebsiteData = NULL;

		}

	}
	return true;
}