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

📄 mainfrm.cpp

📁 1.MyIE开源工程协议 MyIE开源工程遵循GNU通用公共许可证GPL(GNU General Public License)开发,任何人都可以永久免费安装使用,在你下载和使用MyIE源代码前,请
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	//
	m_bMenuLoadLastClose = app->GetProfileInt("Settings", "MenuLoadLastClose", 1);
	if (m_bMenuLoadLastClose)
		OpenLastClose();

	return 0;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CMDIFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CMDIFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers

void CMainFrame::SetAddress(LPCTSTR lpszUrl)
{
	// This is called when the browser has completely loaded the new location,
	// so make sure the text in the address bar is up to date and stop the
	try{
	m_wndAddress->SetWindowText(lpszUrl);
	COMBOBOXEXITEM item;
	item.mask = CBEIF_IMAGE|CBEIF_SELECTEDIMAGE ;
	item.iItem = -1;
	item.iImage = 1;
	item.iSelectedImage = 1;
	m_wndAddress->SetItem(&item);
	}catch(...){}
}

void CMainFrame::OnNewAddress()
{
	// gets called when an item in the Address combo box is selected
	// just navigate to the newly selected location.
	CString str;

	try{
	int i = m_AddressBar.m_wndAddress.GetCurSel();
	if(i<0)
		return;
	m_AddressBar.GetSelText(i, str);
	//
	if (DoSpecialUrl(str))
		return;
	if (IS_RES_URL(str))
	{
		DO_RES_URL(str)
		m_wndAddress->GetEditCtrl()->SetWindowText(str);
	}

	CChildFrame* tcf = (CChildFrame*)MDIGetActive();
	short ks=GetKeyState(VK_CONTROL), ss=GetKeyState(VK_SHIFT);
	//create new if not exist
	if(tcf==NULL || g_bAddressInNewWindow)
	{
		CString strProxy;
		strProxy.Empty();
		if (VALID_TCF(tcf) && tcf->m_pView->m_bEnWebProxy)
		{
			strProxy = tcf->m_pView->m_strWebProxy;
		}
		tcf = NewChildWindow(0);
		if (VALID_TCF(tcf) && strProxy.GetLength()>0)
		{
			tcf->m_pView->m_bEnWebProxy = 1;
			tcf->m_pView->m_strWebProxy = strProxy;
		}
		if (m_bActiveNewAddress)
			tcf->m_bForceActive = TRUE;
	}
	//web proxy
	if (VALID_TCF(tcf))
	{
		tcf->m_pView->ToNavigate(str, 0, NULL);
		//
		tcf = (CChildFrame*)MDIGetActive();
		tcf->ViewSetFocus();//must use post
	}
	}catch(...){}
}

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.
	CString oldstr, url;
	CString str, str2;
	COMBOBOXEXITEM item;

	try{
	if ( (CWnd*)m_wndSearch->GetEditCtrl() == GetFocus() )
	{
		OnNewSearchEnter();
		return;
	}
	//
	m_wndAddress->GetEditCtrl()->GetWindowText(str2);
	str2.TrimLeft();str2.TrimRight();
	if (str2.GetLength()<=0)
		return;
	//focus
	m_wndAddress->SetFocus();
	//
	if (DoSpecialUrl(str2))
		return;
	if (IS_RES_URL(str2))
	{
		DO_RES_URL(str2)
		m_wndAddress->GetEditCtrl()->SetWindowText(str2);
	}

	CChildFrame* tcf = (CChildFrame*)MDIGetActive();
	//GetKeyState return >0 means press the key
	short ks=GetKeyState(VK_CONTROL), ss=GetKeyState(VK_SHIFT), as=GetKeyState(VK_MENU);
	if(ks>=0 && ss>=0) // only Enter need to expand alias and other shortcuts
	{
		//alisa
		if(m_bUseAlias && m_mapAlias.Lookup(str2, url))
		{
			str2 = url;
			m_wndAddress->GetEditCtrl()->SetWindowText(str2);
		}
		//use quick search
		else if(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_SearchList.Lookup(qs, url)!=-1)
			{
				DO_SEARCH_STR(url,keyw)
				str2 = url;
				m_wndAddress->GetEditCtrl()->SetWindowText(str2);
			}
		}
	}
	oldstr = str2;
	item.mask = CBEIF_TEXT|CBEIF_IMAGE|CBEIF_SELECTEDIMAGE ;
	item.iItem = 0;
	str2.TrimLeft();
	str2.TrimRight();
	
	//javascript:void(document.bgColor='#FFFFFF')
	//books://www.
	if (str2.Find(':')>0)
		str2.Replace('\\','/');
	else
	{
		if(ks<0 && ss>=0 && as>=0)
			str2 = m_strCE1+str2+m_strCE2;
		else if(ks>=0 && ss<0 && as>=0)
			str2 = m_strSE1+str2+m_strSE2;
		else if(ks<0 && ss<0 && as>=0)
			str2 = m_strCSE1 + str2 + m_strCSE2;
		else if (str2=="localhost")
			str2 = "http://"+str2;
		else if (str2.Left(4)=="ftp.")
			str2 = "ftp://"+str2;
		else if (NOT_SEARCH_STR(str2))
		{
			if (str2.Left(2)!="\\\\") // \\server1
				str2 = "http://"+str2;
		}
		else//search
		{
			SEARCH_STR(str2)
			return;
		}
		oldstr = str2;
		m_wndAddress->GetEditCtrl()->SetWindowText(str2);
	}
	str =str2;

	//create new if not exist and always new
	if(tcf==NULL || g_bAddressInNewWindow || as<0)
	{
		CString strProxy;
		strProxy.Empty();
		if (VALID_TCF(tcf) && tcf->m_pView->m_bEnWebProxy)
		{
			strProxy = tcf->m_pView->m_strWebProxy;
		}
		tcf = NewChildWindow(0);
		if (VALID_TCF(tcf) && strProxy.GetLength()>0)
		{
			tcf->m_pView->m_bEnWebProxy = 1;
			tcf->m_pView->m_strWebProxy = strProxy;
		}
		if (m_bActiveNewAddress)
			tcf->m_bForceActive = TRUE;
	}
	//web proxy
	if (VALID_TCF(tcf))
	{
		tcf->m_pView->ToNavigate(oldstr, 0, NULL);
		//
		tcf = (CChildFrame*)MDIGetActive();
		tcf->ViewSetFocus();
	}

	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(...){}
}

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)
{
	CString         strPath; 
	CString         strPath2;
	CString         str, str2;
	WIN32_FIND_DATA wfd;
	HANDLE          h;
	int             nPos;
	int             nEndPos;
	int             nLastDir;
	CStringArray    astrFavorites;
	CArray<int,int>	anFavID;
	CStringArray    astrDirs;
	BOOL			isLink = FALSE;
	static CString	strOpenAll, strAddFav;
	int				nSubFavs = 0;

	try{
	strPath = pszPath;
	nFavs = 0;
	LOADSTR(strOpenAll ,IDS_OPEN_ALL_FAV);
	LOADSTR(strAddFav ,IDS_ADDFAV);
	// make sure there's a trailing backslash
	if(strPath[strPath.GetLength() - 1] != _T('\\'))
		strPath += _T('\\');
	//for relative path
	CString strLinkPath = m_strLinkPath;
	DO_RELATIVE_URL(strLinkPath);
	if(strPath==strLinkPath)
		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);
	DWORD fileattr;
	if(m_bShowHiddenFav == 1)
		fileattr = FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_SYSTEM;
	else
		fileattr = FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM;
	if(h != INVALID_HANDLE_VALUE)
	{
		nEndPos = nStartPos;
		do
		{
			if((wfd.dwFileAttributes & fileattr)==0)
			{
				str = wfd.cFileName; str2= str;
				if (IS_FAVURL(str))
				{
					nPos = nEndPos;
					astrFavorites.Add( str2);
					anFavID.Add(nPos);
					++nEndPos;
					nFavs ++;
				}
				else if(str.Right(4) == _T(".lnk"))
				{
					nPos = nEndPos;
					astrFavorites.Add(str2);
					anFavID.Add(nPos);
					++nEndPos;
					nFavs ++;
				}
			}
			else if((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (m_bShowHiddenFav==1 || (wfd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)==0))
			{
				// 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);
	}

	// 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;
						FavMenuAddURL(astrFavorites[j], strPath2, FirstLevel, isLink, pMenu, anFavID[j]);
						astrFavorites[j].Empty();
					}
				}
				for(j = 0; j<astrDirs.GetSize() && !found && (type==0x10 || type==0x14 || type==0); j++)
				{
					if(astrDirs[j].CompareNoCase(str)==0)
					{
						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, FirstLevel, isLink, pMenu, anFavID[i]);
	}
	//add a break if needed
	if(!g_bSingleMenu)
		AddMenuBreak(pMenu,2);
	if(isLink)
	{
		CRect rectToolBar;
		REBARBANDINFO rbbi;
		m_LinkBar.GetItemRect(0, &rectToolBar);
		
		rbbi.cbSize = sizeof(rbbi);
		rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE /*| RBBIM_SIZE*/ |RBBIM_ID;// |RBBIM_STYLE;
		rbbi.wID = ID_VIEW_LINKS;
		rbbi.cxMinChild = 0;
		if(rectToolBar.Height()<22)

⌨️ 快捷键说明

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