⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 myie的源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	if(m_bSecure)
	{
		int i = str.Find(':');
		CString po = str.Left(i);
		po.MakeLower();
		if(i==1 || po == "file")
			return;
	}

	CChildFrame* tcf = (CChildFrame*)MDIGetActive();

	//decode the escape characters
//	DecodeEscap(str);
	short ks=GetKeyState(VK_CONTROL), ss=GetKeyState(VK_SHIFT);
	if(m_bUse3721 && ks>=0 && ss>=0)
	{
		//use 3721
		if(str.Find(':')<0 && str.Find('.')<0)
		{
			//not a url
			str = "http://cns.3721.com/cns.dll?platform=pc&fl=1&fd=1&name="+str; // www.3721.com/***
		}
	}

	//create new if not exist
	if(tcf==NULL || bAddressInNewWindow)
		tcf = NewChildWindow(0);

	//web proxy
	if (tcf!=NULL && tcf->m_pView!=NULL)
	{
		tcf->m_pView->ToNavigate(str, 0, NULL);

	}
	
	}/*catch(CMemoryException * e)
	{
		if(e!=NULL)e->Delete();
	}*/
	catch(...)
	{
//		AfxMessageBox("new address error");
	}

}


void CMainFrame::OnNewAddressEnter()
{
	// gets called when an item is entered manually into the edit box portion
	// of the Address combo box.
	// navigate to the newly selected location and also add this address to the
	// list of addresses in the combo box.
	//static CString str;
	CString oldstr, url;
	CString str, str2;
	COMBOBOXEXITEM item;

	try
	{

	//focus
	m_wndAddress->SetFocus();

	m_wndAddress->GetEditCtrl()->GetWindowText(str2);
	str2.TrimLeft();str2.TrimRight();
	if(m_bSecure)
	{
		int i = str2.Find(':');
		CString po = str2.Left(i);
		po.MakeLower();
		if(i==1 || po == "file")
			return;
	}

	CChildFrame* tcf = (CChildFrame*)MDIGetActive();
	short ks=GetKeyState(VK_CONTROL), ss=GetKeyState(VK_SHIFT);
	
	BOOL use3721 = FALSE;

	if(ks>=0 && ss>=0) // only Enter need to expand alias and other shortcuts
	{
		//alisa
		if(m_bUseAlias)
			if(m_mapAlias.Lookup(str2, url))
				str2 = url;
			else
				use3721=TRUE;
		else
			use3721=TRUE;

		//use quick search
		if(use3721 && str2.Find(' ')>0)
		{
			int i = str2.Find(' ');
			CString qs = str2.Left(i);
			CString keyw = str2.Mid(i+1);
			keyw.TrimLeft();
			qs.TrimLeft();qs.TrimRight();
			if(m_QuickSearchMap->Lookup(qs, url))
			{
				str2 = url;
				str2.Replace("%s", keyw);
				use3721 = FALSE;
			}
		}
	}

	if(m_bUse3721 && use3721 && ks>=0 && ss>=0)
	{
		//use 3721
		if(str2.Find(':')<0 && str2.Find('.')<0)
		{
			//not a url
			url = str2;
			//http://cns.3721.com/cns.dll?platform=pc&fl=1&fd=1&name=
			str2 = "http://cns.3721.com/cns.dll?type=cns&fa=1&name="+str2; // www.3721.com/***
		}
		else
			use3721 = FALSE;
	}
	else
		use3721 = FALSE;

	oldstr = str2;


	item.mask = CBEIF_TEXT|CBEIF_IMAGE|CBEIF_SELECTEDIMAGE ;
	item.iItem = 0;

	//format the URL string
	if(!use3721)
	{
		str2.TrimLeft();
		str2.TrimRight();
	}
	int co = str2.Find(':');
	if(co > 1)
		str2.Replace('\\','/');
	if(co < 0)
	{
		if(ks<0 && ss>=0)
			str2 = m_strCE1+str2+m_strCE2;
		else if(ks>=0 && ss<0)
			str2 = m_strSE1+str2+m_strSE2;
		else if(ks<0 && ss<0)
			str2 = m_strCSE1 + str2 + m_strCSE2;
		else
			str2 = "http://"+str2;

		if(ks<0 || ss<0)
		{
			oldstr = str2;
			m_wndAddress->GetEditCtrl()->SetWindowText(str2);
		}
	}


	if(use3721)
		str2 = url;
	
	str =str2;


	short as=GetKeyState(VK_MENU);
	//create new if not exist and always new
	if(tcf==NULL || bAddressInNewWindow || as<0)
		tcf = NewChildWindow(0);

	//web proxy
	if (tcf!=NULL && tcf->m_pView!=NULL)
	{
		tcf->m_pView->ToNavigate(oldstr, 0, NULL);
	}

	if(m_AddressBar.FindStringExact(-1,str) == CB_ERR)
	{
		if (str.Right(1)=='/')
			str = str.Left(str.GetLength()-1);
		else
			str += '/';

		if(m_AddressBar.FindStringExact(-1, str) == CB_ERR)
		{
			//the URL is new
			item.pszText = (LPTSTR)(LPCTSTR)str2;
			item.iImage = 1;
			item.iSelectedImage = 1;
			m_wndAddress->InsertItem(&item);

		}
	}

	}
/*	catch(CMemoryException * e)
	{
		if(e!=NULL)e->Delete();
//		AfxMessageBox("new address enter error");
	}*/
	catch(...)
	{
	}
}

void CMainFrame::DoNothing()
{
	// this is here only so that the toolbar buttons for the dropdown menus
	// will have a callback, and thus will not be disabled.
}


int CMainFrame::BuildFavoritesMenu(LPCTSTR pszPath, int nStartPos, CMenu* pMenu,int nFixMenu, int FirstLevel, int& nFavs, int& nMostFavs)
{
	CString         strPath; 
	CString         strPath2;
	CString         str, str2;
	WIN32_FIND_DATA wfd;
	HANDLE          h;
	int             nPos;
	int             nEndPos;
	int             nLastDir;
//	TCHAR           buf[INTERNET_MAX_PATH_LENGTH];
	CStringArray    astrFavorites;
	CArray<int,int>	anFavID;
	CStringArray    astrDirs;
//	CMenu*          pSubMenu;
	BOOL			isLink = FALSE;
	static CString			strOpenAll, strOpenMost, strAddFav;
	int				nSubFavs = 0, nSubMostFavs = 0;


	try
	{
	strPath = pszPath;

	nFavs = 0; nMostFavs = 0;
	
	strOpenAll.LoadString(IDS_OPEN_ALL_FAV);
	strOpenMost.LoadString(IDS_OPEN_ALL_MOSTFAV);
	strAddFav.LoadString(IDS_ADDFAV);

	// make sure there's a trailing backslash
	if(strPath[strPath.GetLength() - 1] != _T('\\'))
		strPath += _T('\\');
	if(strPath==m_strLinkFolder)
		isLink = TRUE;

	strPath2 = strPath;
	strPath += "*.*";

	nLastDir = 0;
	// now scan the directory, first for .URL files and then for subdirectories
	// that may also contain .URL files
	h = FindFirstFile(strPath, &wfd);
	if(h != INVALID_HANDLE_VALUE)
	{
		nEndPos = nStartPos;
		do
		{
			if((wfd.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))==0)
			{
				str = wfd.cFileName; str2= str;
				str.MakeLower();
				if(str.Right(4) == _T(".url"))
				{
					nPos = nEndPos;
					astrFavorites.Add( str2);
					anFavID.Add(nPos);
				//	m_astrFavoriteURLs.InsertAt(nPos, buf);
					++nEndPos;
					nFavs ++;
				}
				else if(str.Right(4) == _T(".lnk"))
				{
					//if(ResolveLink(strPath2 + str, buf))
					{

						// scan through the array and perform an insertion sort
						// to make sure the menu ends up in alphabetic order
						/*for(nPos = nStartPos ; nPos < nEndPos ; ++nPos)
						{
							if(str.CompareNoCase(astrFavorites[nPos]) < 0)
								break;
						}*/
						nPos = nEndPos;
						//m_astrFavoriteURLs.InsertAt(nPos, buf);
				//		m_astrFavoriteURLs.InsertAt(nPos, strPath2 + str);
						//str2 = str2.Left(str2.GetLength() - 4);
						astrFavorites.Add(str2);
						anFavID.Add(nPos);
						++nEndPos;
						nFavs ++;
					}
				}
			}
			else if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
			{
				// ignore the current and parent directory entries
				if(lstrcmp(wfd.cFileName, _T(".")) == 0 || lstrcmp(wfd.cFileName, _T("..")) == 0 )//|| lstrcmp(wfd.cFileName, strcha) == 0 || lstrcmp(wfd.cFileName, strcha2) == 0
					continue;

				astrDirs.Add(wfd.cFileName); 
				nLastDir++;	
			}
		} while(FindNextFile(h, &wfd));
		FindClose(h);

	}


		
		
		if(isLink)
		{
			//remove all link buttons
			int b = m_LinkBar.GetToolBarCtrl().GetButtonCount();
			for(int i = 1; i<b;i++)
				m_LinkBar.GetToolBarCtrl().DeleteButton(1);

			REBARBANDINFO rbbi;

			rbbi.cbSize = sizeof(rbbi);
			rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE |RBBIM_ID ;
			rbbi.wID = ID_VIEW_LINKS;
			rbbi.cxMinChild = 2;
			rbbi.cyMinChild = 22;
			/*rbbi.cx =*/ rbbi.cxIdeal = 2;

			int bandid = m_wndReBar.GetReBarCtrl().IDToIndex(ID_VIEW_LINKS);
			m_wndReBar.GetReBarCtrl().SetBandInfo(bandid, &rbbi);
		}

		if(FirstLevel)
		{
			//remove all Fav buttons
			int b = m_FavBar.GetToolBarCtrl().GetButtonCount();
			for(int i = 0; i<b;i++)
				m_FavBar.GetToolBarCtrl().DeleteButton(0);

			REBARBANDINFO rbbi;

			rbbi.cbSize = sizeof(rbbi);
			rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE |RBBIM_ID ;
			rbbi.wID = ID_VIEW_FAVS;
			rbbi.cxMinChild = 2;
			rbbi.cyMinChild = 22;
			/*rbbi.cx =*/ rbbi.cxIdeal = 2;

			int bandid = m_wndReBar.GetReBarCtrl().IDToIndex(ID_VIEW_FAVS);
			m_wndReBar.GetReBarCtrl().SetBandInfo(bandid, &rbbi);
		}

//////////////////////////////// Now add these items to the menu
		CMenuOrder mo;
		BOOL found;
		int j;
		WORD type;
		if(GetFavoriteFolder(strPath))
		{
			strPath = strPath2.Mid(strPath.GetLength()+1);
			if(mo.LoadMenuOrder(strPath))
			{
				for(int i = 0; i<mo.len; i++)
				{
					str = mo.mois[mo.index[i]].longname;
					type = mo.mois[mo.index[i]].filetype;
					//find in url first
					found = FALSE;
					for(j = 0; j<astrFavorites.GetSize() && !found && (type==0x20 || type==0); j++)
					{
						if(astrFavorites[j].CompareNoCase(str)==0)
						{
							found = TRUE;
							//add
							FavMenuAddURL(astrFavorites[j], strPath2, isLink, pMenu, anFavID[j], nMostFavs);
							astrFavorites[j].Empty();
						}
					}
					for(j = 0; j<astrDirs.GetSize() && !found && (type==0x10 || type==0x14 || type==0); j++)
					{
						if(astrDirs[j].CompareNoCase(str)==0)
						{
							//add
							FavMenuAddFolder(astrDirs[j], strPath2, FirstLevel, isLink, pMenu, nEndPos);
							astrDirs[j].Empty();
						}
					}

				}
			}
		}

		//sort dirs and favs
		CString tmp;
		int n = astrDirs.GetSize();
		int i, ch, m;
		ch = n;
		while(ch>0)
		{
			m = ch-1; ch = 0;
			for(i=1; i<=m; i++)
			{
				if(lstrcmp(astrDirs[i-1], astrDirs[i])>0)
				{
					tmp = astrDirs[i-1];
					astrDirs[i-1] = astrDirs[i];
					astrDirs[i] = tmp;
					ch = i;
				}
			}
		}
		
		n = astrFavorites.GetSize();
		ch = n;
		int ntmp;
		while(ch>0)
		{
			m = ch-1; ch = 0;
			for(i=1; i<=m; i++)
			{
				if(lstrcmpiA(astrFavorites[i-1], astrFavorites[i])>0)
				{
					tmp = astrFavorites[i-1];
					astrFavorites[i-1] = astrFavorites[i];
					astrFavorites[i] = tmp;
					ntmp = anFavID[i-1];
					anFavID[i-1] = anFavID[i];
					anFavID[i] = ntmp;
					ch = i;
				}
			}
		}	

		for(i = 0; i<astrDirs.GetSize(); i++)
		{
			if(astrDirs[i].IsEmpty())
				continue;
			FavMenuAddFolder(astrDirs[i], strPath2, FirstLevel, isLink, pMenu, nEndPos);
		}		
				
		for(i = 0 ; i < astrFavorites.GetSize() ; i++)
		{
			if(astrFavorites[i].IsEmpty())
				continue;
			FavMenuAddURL(astrFavorites[i], strPath2, isLink, pMenu, anFavID[i], nMostFavs);
		}
		
		

/////////////////////////////////////////////////////////////////



		
	//add a break if needed
	if(!bSingleMenu)
		AddMenuBreak(pMenu);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -