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

📄 mainfrm.cpp

📁 myie2.4版本的源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	}
	
	}/*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();
	CChildFrame* tcf = (CChildFrame*)MDIGetActive();
	
	BOOL use3721 = FALSE;
	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();
		if(m_QuickSearchMap.Lookup(qs, url))
		{
			str2 = url;
			str2.Replace("%s", keyw);
			use3721 = FALSE;
		}
	}

	short ks=GetKeyState(VK_CONTROL), ss=GetKeyState(VK_SHIFT);
	if(m_bUse3721 && use3721 && ks>=0 && ss>=0)
	{
		//use 3721
		if(str2.Find(':')<0 && str2.Find('.')<0)
		{
			//not a url
			url = str2;
			str2 = "http://cns.3721.com/cns.dll?platform=pc&fl=1&fd=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.
}

void CMainFrame::OnDropDown(NMHDR* pNotifyStruct, LRESULT* pResult)
{
	// this function handles the dropdown menus from the toolbar
	NMTOOLBAR* pNMToolBar = (NMTOOLBAR*)pNotifyStruct;
	CRect rect;

	try{

	// translate the current toolbar item rectangle into screen coordinates
	// so that we'll know where to pop up the menu
	if(pNMToolBar->iItem == IDOK)
		m_AddressBar.GetToolBarCtrl().GetRect(pNMToolBar->iItem, &rect);
	else
		m_wndToolBar.GetToolBarCtrl().GetRect(pNMToolBar->iItem, &rect);
	rect.top = rect.bottom;
	::ClientToScreen(pNMToolBar->hdr.hwndFrom, &rect.TopLeft());
	if(pNMToolBar->iItem == ID_FONT_DROPDOWN)
	{
		CMenu menu;
		CMenu* pPopup;

		// the font popup is stored in a resource
		menu.LoadMenu(IDR_FONT_POPUP);
		pPopup = menu.GetSubMenu(0);
		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rect.left, rect.top + 1, AfxGetMainWnd());
	}
	else if(pNMToolBar->iItem == ID_NEWWINDOW)
	{
		CMenu* pPopup;
		pPopup = GetMenu()->GetSubMenu(0)->GetSubMenu(0);
		pPopup->SetDefaultItem(m_nNewWindow, TRUE);

		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rect.left, rect.top + 1, AfxGetMainWnd());
	}
	else if(pNMToolBar->iItem == ID_OPTIONS_LOADIMAGE)
	{
		CMenu* pPopup;
		pPopup = GetMenu()->GetSubMenu(6)->GetSubMenu(0);

		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rect.left, rect.top + 1, AfxGetMainWnd());
	}
	else if(pNMToolBar->iItem == ID_EDIT_UNDOCLOSE)
	{
		CMenu* pPopup;
		pPopup = GetMenu()->GetSubMenu(1)->GetSubMenu(0);

		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rect.left, rect.top + 1, AfxGetMainWnd());
	}
	else if(pNMToolBar->iItem == ID_OPTIONS_USE_PROXY)
	{
		CMenu pPopup;
		INTERNET_PROXY_INFO ipi;
		DWORD dwSize=sizeof(ipi);
		BOOL bUseProxy;

		//This call determines the buffer size needed
		InternetQueryOption(NULL,INTERNET_OPTION_PROXY,&ipi,&dwSize);
		//Insert code to user the user agent string information
		if (ipi.dwAccessType == INTERNET_OPEN_TYPE_DIRECT )
			bUseProxy = FALSE;
		else
			bUseProxy = TRUE;

		pPopup.CreatePopupMenu();
//		POSITION pos1=m_aProxySpeed.GetHeadPosition(), pos = m_astrProxy.GetHeadPosition(), pos2 = m_astrProxyName.GetHeadPosition();
		int i=0;
		CString str, str1;
/*		while(pos!=NULL && pos1!=NULL && pos2!=NULL)
		{
			str = m_astrProxyName.GetAt(pos2);
			str = str.Left(50);
			str1.LoadString(IDS_SP_INVALID + m_aProxySpeed.GetAt(pos1));
			str1 = "(" + str1 + ")";
			if(str.Left(1)=="-")
			{
				pPopup.AppendMenu(MF_GRAYED|MF_STRING|MF_DISABLED, 0, str);
			}
			else
				pPopup.AppendMenu(MF_STRING, 0x1100 + i, str+str1);
			if(bUseProxy && m_strCurProxy == m_astrProxy.GetAt(pos))
				pPopup.CheckMenuItem(0x1100 + i, MF_CHECKED | MF_BYCOMMAND );
			m_astrProxy.GetNext(pos);
			m_aProxySpeed.GetNext(pos1);
			m_astrProxyName.GetNext(pos2);
			i++;
		}*/
		CProxyList* pl;
		CMenu submenu;
		int pindex = 0;
		int pcates = 0;
		for(int l = 0;l <= m_aProxyCategories.m_ProxyCategory.GetUpperBound();l++)
		{	
			pl = m_aProxyCategories.m_ProxyCategory.GetAt(l);
			if(pl!=NULL && !pl->m_bIsWebProxy)
				pcates++;
		}
		for(l = 0;l <= m_aProxyCategories.m_ProxyCategory.GetUpperBound();l++)
		{
			pl = m_aProxyCategories.m_ProxyCategory.GetAt(l);
			if(pl!=NULL && !pl->m_bIsWebProxy)
			{
				if(pcates>1)
					submenu.CreatePopupMenu();
				for(i=0; i<=pl->m_Proxies.GetUpperBound(); i++)
				{
					str = pl->m_Proxies.ElementAt(i).m_strProxyName;
					if(str.Left(2)=="--")
					{
						if(pcates>1)
							//submenu.AppendMenu(MF_GRAYED|MF_STRING|MF_DISABLED, 0, str);
							submenu.AppendMenu(MF_SEPARATOR);
						else if(pcates==1)
							//pPopup.AppendMenu(MF_GRAYED|MF_STRING|MF_DISABLED, 0, str);
							pPopup.AppendMenu(MF_SEPARATOR);
					}
					else
					{
						str = str.Left(50);
						str1.LoadString(IDS_SP_INVALID + pl->m_Proxies.ElementAt(i).m_nProxySpeed);
						str1 = "(" + str1 + ")";

						if(pcates>1)
							submenu.AppendMenu(MF_STRING, 0x1100 + pindex, str+str1);
						else if(pcates==1)
							pPopup.AppendMenu(MF_STRING, 0x1100 + pindex, str+str1);
						pl->m_Proxies.ElementAt(i).index = pindex;
						if(bUseProxy && m_strCurProxy == pl->m_Proxies.ElementAt(i).m_strProxy)
						{
							if(pcates>1)
								submenu.CheckMenuItem(0x1100 + pindex, MF_CHECKED | MF_BYCOMMAND );
							else if(pcates==1)
								pPopup.CheckMenuItem(0x1100 + pindex, MF_CHECKED | MF_BYCOMMAND );
						}
						pindex++;
					}
				}
				if(pcates>1)
				{
					pPopup.AppendMenu(MF_POPUP, (UINT)submenu.m_hMenu, pl->m_strCategoryName);
					submenu.Detach();
				}
			}
		}

		pPopup.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rect.left, rect.top + 1, AfxGetMainWnd());
		pPopup.DestroyMenu();
	}
	else if(pNMToolBar->iItem == ID_OPTIONS_USE_WEBP || pNMToolBar->iItem == IDOK)
	{
		m_dwWebProxyFrom = pNMToolBar->iItem;
		CMenu pPopup;
		CString strCurWebProxy;
		CChildFrame* tcf = (CChildFrame*)MDIGetActive();
		if (tcf!=NULL && tcf->m_pView!=NULL)
		{
			if(((CMyIEView*)tcf->m_pView)->m_bEnWebProxy)
			{
				strCurWebProxy = ((CMyIEView*)tcf->m_pView)->m_strWebProxy;
			}
		}

		pPopup.CreatePopupMenu();
//		POSITION pos = m_astrWebProxy.GetHeadPosition(), pos1 = m_aWebProxySpeed.GetHeadPosition(), pos2 = m_astrWebProxyName.GetHeadPosition();
		CProxyList* pl = m_aProxyCategories.GetWebProxyList();
		int i=0;
		CString str, str1;
/*		while(pos!=NULL && pos1!=NULL && pos2!=NULL)
		{
			str = m_astrWebProxyName.GetAt(pos2);
			str1.LoadString(IDS_SP_INVALID + m_aWebProxySpeed.GetAt(pos1));
			str1 = "(" + str1 + ")";

			pPopup.AppendMenu(MF_STRING, 0x1200 + i, str+str1);
			if(strCurWebProxy == m_astrWebProxy.GetAt(pos))
				pPopup.CheckMenuItem(0x1200 + i, MF_CHECKED | MF_BYCOMMAND );
			m_astrWebProxy.GetNext(pos);
			m_aWebProxySpeed.GetNext(pos1);
			m_astrWebProxyName.GetNext(pos2);
			i++;
		}*/
		if(pl!=NULL)
			for(i=0; i<=pl->m_Proxies.GetUpperBound(); i++)
			{
				str = pl->m_Proxies.ElementAt(i).m_strProxyName;
				if(str.Left(2)=="--")
					pPopup.AppendMenu(MF_SEPARATOR);
				else
				{
					str = str.Left(50);
					str1.LoadString(IDS_SP_INVALID + pl->m_Proxies.ElementAt(i).m_nProxySpeed);
					str1 = "(" + str1 + ")";

					pPopup.AppendMenu(MF_STRING, 0x1200 + i, str+str1);
					if(strCurWebProxy == pl->m_Proxies.ElementAt(i).m_strProxy)
						pPopup.CheckMenuItem(0x1200 + i, MF_CHECKED | MF_BYCOMMAND );
				}
			}
		
		pPopup.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rect.left, rect.top + 1, AfxGetMainWnd());
		pPopup.DestroyMenu();
	}
	else if(pNMToolBar->iItem == ID_ENCODE_DROPDOWN)
	{
		CMenu menu;
		CMenu* pPopup;

		// the font popup is stored in a resource
		menu.LoadMenu(IDR_ENCODING);
		pPopup = menu.GetSubMenu(0);
		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rect.left, rect.top + 1, AfxGetMainWnd());
	}
	else if(pNMToolBar->iItem == ID_BMODE_DROPDOWN)
	{
		CMenu* pPopup;
		pPopup = GetMenu()->GetSubMenu(6)->GetSubMenu(13);

		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rect.left, rect.top + 1, AfxGetMainWnd());
	}
	else if(pNMToolBar->iItem == ID_TOOLS_AUTOSCROLL_USEAUTOSCROLLING)
	{
		CMenu* pPopup;
		pPopup = GetMenu()->GetSubMenu(7)->GetSubMenu(17);

		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rect.left, rect.top + 1, AfxGetMainWnd());
	}
	else if(pNMToolBar->iItem == ID_GO_BACK)
	{
		try{

		CMenu pPopup;
		CChildFrame* tcf = (CChildFrame*)MDIGetActive();
		if (tcf!=NULL && tcf->m_pView!=NULL)
		{
			// the font popup is stored in a resource
			pPopup.CreatePopupMenu();
			int i=0, l=0;
			for(i=tcf->m_pView->m_nCurHistory-1; i>=0 && l<9; i--)
			{
				if(tcf->m_pView->m_astrHistory.GetAt(i).IsEmpty())
					pPopup.AppendMenu(MF_STRING, l+1, tcf->m_pView->m_astrHistoryURL.GetAt(i));
				else
					pPopup.AppendMenu(MF_STRING, l+1, tcf->m_pView->m_astrHistory.GetAt(i));

				l++;
			}

			
			int cmd = pPopup.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, rect.left, rect.top + 1, AfxGetMainWnd());
			pPopup.DestroyMenu();

			//2.2
			if(cmd>0)
				tcf->m_pView->GoBack(cmd);

		/*	if(cmd>0)
			{
				LPDISPATCH pDisp = NULL;
				IHTMLDocument2 *pHTMLDoc = NULL;
				IHTMLWindow2 *pHTMLWnd = NULL;
				IOmHistory  *pHistory = NULL;
				VARIANT v;
				v.vt = VT_I2;
				v.iVal = cmd;
				try{
					//get history length
					pDisp = tcf->m_pView->GetHtmlDocument();
					if( pDisp )
					{
						if(SUCCEEDED(pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pHTMLDoc)))
						{
							if(SUCCEEDED(pHTMLDoc->get_parentWindow( &pHTMLWnd )))
							{
								if(SUCCEEDED(pHTMLWnd->get_history( &pHistory )))
								{

⌨️ 快捷键说明

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