📄 myieview.cpp
字号:
if(liFreq.LowPart!=0)
{
double secs = (double)(liFinish.LowPart - m_tLastClick.LowPart)/(double)liFreq.LowPart;
if(secs<POP_DELAY && secs>0)
{
if (g_bKillPop && g_bKillDupWin)
{
int dup = pmf->FindDupURL(lpszURL, tcf);
if(dup<0)
bCanNew = TRUE;
else
{
*pbCancel = TRUE;
TabCtrlItem.mask = TCIF_PARAM;
pmf->m_wndTab.GetItem(dup, &TabCtrlItem);
CChildFrame* tcf2 = (CChildFrame*)TabCtrlItem.lParam;
if(tcf2!=NULL && tcf2!=tcf)
pmf->MDIActivate(tcf2);
}
}
else
bCanNew = TRUE;
}
else
m_tLastClick.LowPart = 0;
}
}
//
if(!m_bFirst && pmf!=NULL && bCanNew)
{
char* pdest = strchr(lpszURL, '#');
if(pdest!=NULL)
{
if(strncmp(lpszURL, m_lpszUrl, pdest - lpszURL)!=0)
pdest = NULL;
}
BOOL bScript = IS_SCRIPT_STR(lpszURL);
if ( !bScript && !IS_MAILTO_STR(lpszURL) && pdest==NULL )
{
CChildFrame *tcf = NULL;
tcf = pmf->NewChildWindow(0,1, NULL, this);
if(tcf != NULL)
{
tcf->m_pView->m_dwProperty = m_dwProperty;
tcf->m_pView->m_bIsNewPopup = FALSE; //TRUE;
tcf->m_pView->m_bFirst = TRUE;
tcf->m_pView->m_nProgress = 0;
//must before native
tcf->m_nActive = m_nInNewWindow;
tcf->m_bForceActive = m_nInNewWindow & INW_ACTIVE;
//for that OnCreateClient will modify m_bIsActive, modify back at here
tcf->m_pView->m_bIsActive = (CAN_ACTIVE(tcf) ? TRUE : FALSE);
m_nInNewWindow = 0;
//
tcf->m_pView->ToNavigate(lpszURL);
if(pbCancel!=NULL)
*pbCancel = TRUE;
m_strOpenNewUrl = lpszURL;
return;
}
}
//not clear script link, it will open in OnNewWindow2
if (!bScript)
m_nInNewWindow = 0;
}
}//end lock and open new
m_bFirst = FALSE;
m_bForceRefresh = FALSE;
//filter popup
if(g_bKillPop && g_bKillListWin && lpszURL!=NULL && strcmp(lpszURL, "about:blank")!=0 && strUrlNew==m_lpszUrl)
{
if (pmf->NeedPopFilter(strUrlNew))
{
if (pmf->ConfirmPopupFilter(strUrlNew, FALSE))
{
if(pbCancel!=NULL)
*pbCancel = TRUE;
m_bIsPopUp = TRUE;
m_strPossibleURL = strUrlNew;
m_nProgress = -1;
//add counter
nFilterType = 2;
pmf->AddToPopList(strUrlNew, nFilterType);
}
}
else
{
m_nProgress = 0;
if(m_bIsActive)
{
//if "mailto:" then not chang g_nPercent
if (strUrl.Left(5)=="http:" || strUrl.Left(5)=="file:" || strUrl.Find(':')==1)
{
g_nPercent = m_nProgress;
//
int nIcon = m_nProgress/34+1;
int nTabID = pmf->FindTab((CChildFrame*)GetParentFrame());
if(m_nProgress>=0)
pmf->SetTabIcon( nIcon, nTabID, this );
}
}
}
}
//filter duplicate url
if(g_bKillPop && g_bKillDupWin && m_nFilterDup && !m_bIsPopUp && m_bIsNewPopup && pmf!=NULL && lpszURL!=NULL && strcmp(lpszURL, "about:blank")!=0 )//&& strUrlNew==m_lpszUrl)
{
//only filter once the window popup
m_nFilterDup --;
int dup = pmf->FindDupURL(strUrlNew, tcf);
if(dup>=0)
{
//if (pmf->ConfirmPopupFilter(strUrlNew,1))
{
if(pbCancel!=NULL)
*pbCancel = TRUE;
m_bIsPopUp = TRUE;
m_strPossibleURL = strUrlNew;
m_nDupID = dup;
m_nProgress = -1;
m_nFilterDup = 0;
//active that dup window
if(tcf && pmf)
{
TabCtrlItem.mask = TCIF_PARAM;
pmf->m_wndTab.GetItem(m_nDupID, &TabCtrlItem);
CChildFrame* tcf2 = (CChildFrame*)TabCtrlItem.lParam;
if(tcf2!=NULL && tcf2!=tcf)
{
pmf->MDIActivate(tcf2);
//pmf->m_wndTab.SetCurSel(m_nDupID);
}
m_nDupID = -1;
}
}
}
else
{
m_nProgress = 0;
if(m_bIsActive)
{
//if "mailto:" then not chang g_nPercent
if (strUrl.Left(5)=="http:" || strUrl.Left(5)=="file:" || strUrl.Find(':')==1)
{
g_nPercent = m_nProgress;
//
int nIcon = m_nProgress/34+1;
int nTabID = pmf->FindTab((CChildFrame*)GetParentFrame());
if(m_nProgress>=0)
pmf->SetTabIcon( nIcon, nTabID, this );
}
}
}
}
//if have filter not auto pop filter
if (*pbCancel==TRUE)
{
m_bAutoPopWin = FALSE;
//when not have page, list filter this, will make a error window
//but not close dup window
if (nFilterType==0 || nFilterType==2)
{
CChildFrame* tcf = ((CChildFrame*)GetParentFrame());
if(tcf!=NULL)
{
m_bToClose = TRUE;
tcf->PostMessage(WM_CLOSE);
}
}
}
//
if (m_bAutoPopWin)
{
m_bAutoPopWin = FALSE;
BOOL bNeedFilter=pmf->NeedUnPopFilter(strUrlNew);
if (bNeedFilter && pmf->ConfirmPopupFilter(strUrlNew, TRUE))
{
if(pbCancel!=NULL)
*pbCancel = TRUE;
m_bIsPopUp = TRUE;
m_strPossibleURL = strUrlNew;
m_nProgress = -1;
//must close the tcf
CChildFrame* tcf = ((CChildFrame*)GetParentFrame());
if(tcf!=NULL)
{
m_bToClose = TRUE;
tcf->PostMessage(WM_CLOSE);
}
//
pmf->AddToPopList(strUrlNew, 0);
return;
}
}
//secure info
if(strncmp(lpszURL, "https", 5)!=0)
m_bIsSecure = FALSE;
if(m_bIsActive && pmf!=NULL)
pmf->m_bIsSecure = m_bIsSecure;
//reused window
if(!m_bIsPopUp && m_bReUsed && tcf!=NULL && pmf!=NULL && CAN_ACTIVE(tcf))
{
int nTabID = pmf->FindTab(tcf);
//active window
pmf->MDIActivate(tcf);
//select current tab
pmf->m_wndTab.SetCurSel( nTabID );
tcf->m_bForceActive = FALSE;
}
m_bReUsed = FALSE;
//Add a tab to tabbar
if(!m_bIsPopUp && m_bDelayAdd && tcf!=NULL && pmf!=NULL)
{
tcf->ShowWindow(SW_SHOW);
m_bDelayAdd = FALSE;
//add tab
pmf->AddNewTab(tcf);
int nTabID = pmf->FindTab(tcf);
//active window
if (CAN_ACTIVE(tcf))
{
pmf->MDIActivate(tcf);
//select current tab
pmf->m_wndTab.SetCurSel( nTabID );
tcf->m_bForceActive = FALSE;
}
//after use m_nActive, set back to 0, BeforeNavigate2 TargetFrameName will use this
tcf->m_nActive = 0;
//set icon
pmf->SetTabIcon( TI_0, nTabID, this );
//update tab bar
if(pmf->m_nTabStyle==2)
pmf->PostMessage(WM_UPDATE_TAB);
pmf->PostMessage(WM_UPDATE_TAB_TIP);
}
}catch(...){}
}
// these are all simple one-liners to do simple controlling of the browser
void CMyIEView::OnGoBack()
{
if(m_bBack)
GoBack();
}
void CMyIEView::OnGoForward()
{
if(m_bForward)
GoForward();
}
void CMyIEView::OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel)
{
// TODO: Add your specialized code here and/or call the base class
CChildFrame *tcf = NULL;
if(ppDisp == NULL || Cancel == NULL)
return;
try{
*Cancel = TRUE;
*ppDisp = NULL;
//auto filter popup window not opened by user
if(g_bKillPop && g_bKillAutoWin && !PRESS_CTRL)
{
//this window is to be closed, so don't open any other windows from it.
if(m_bToClose)
return;
LARGE_INTEGER liFinish;
LARGE_INTEGER liFreq;
QueryPerformanceCounter(&liFinish);
QueryPerformanceFrequency(&liFreq);
if(liFreq.LowPart!=0)
{
CString strUrl;
double secs = (double)(liFinish.LowPart - m_tLastClick.LowPart)/(double)liFreq.LowPart;
if((secs>POP_DELAY && secs<4.0 && m_bLClick) || m_nProgress==-1)
{
if(m_nProgress>=0)
strUrl = GetPointUrl(m_ptLClick);
else if(GetBusy())//whether browser is busy when m_mPorgress <0
m_nProgress=0;
}
//
try{
if (
!( m_bLClick
&&
( (secs>=0 && secs<=POP_DELAY) || IS_URL(strUrl) || m_nProgress==-1 )
)
)
{
int bFilter = TRUE;
//may click open in new window of pop menu
if (m_bRClick)
{
if (m_bRClick == RC_NOT_FILTER)
{
bFilter = FALSE;//not filter
m_bRClick = 0;
}
else if (!pmf->m_bFilterRefresh)
bFilter = FALSE;
else
{
CString strUrl = GetPointUrl(pmf->m_ptMouseDown);
if (IS_URL(strUrl) || IS_SCRIPT(strUrl))
bFilter = FALSE;//not filter
}
}
//for that here not know the url, have to get the url at OnBeforeNavigate2
if (bFilter)
{
//5.5.27, use may use unfilter list
/*if (!pmf->m_bOutputSaveFilter)
{
pmf->m_nPopFiltered++;
if (pmf->m_bPlayPopupFilterSound)
::sndPlaySound(theApp.m_strRoot+"Resource\\PopFilter.wav", SND_ASYNC);
return;
}
else*/
pmf->m_bAutoPopWin = TRUE;
//return; will get the url in onbeforenavigate
}
}
}catch(...){}
}
}
m_bLClick = FALSE;
//new child window from this
tcf = pmf->NewChildWindow(0,1, NULL, this);
//must do this, for pop in exist blank window
if (pmf->m_bAutoPopWin)
{
tcf->m_pView->m_bAutoPopWin = TRUE;
pmf->m_bAutoPopWin = FALSE;
}
if (m_nInNewWindow)
{
tcf->m_nActive = m_nInNewWindow;
tcf->m_bForceActive = m_nInNewWindow & INW_ACTIVE;
tcf->m_pView->m_bIsActive = (CAN_ACTIVE(tcf) ? TRUE : FALSE);
m_nInNewWindow = 0;
}
//this maybe a blank window.
if(((CChildFrame*)GetParentFrame())->m_pBlankChild != tcf)
{
((CChildFrame*)GetParentFrame())->m_pBlankChild = tcf;
QueryPerformanceCounter(&((CChildFrame*)GetParentFrame())->m_tBlankChild);
}
else
((CChildFrame*)GetParentFrame())->m_pBlankChild = NULL;
tcf->m_pView->m_dwProperty = m_dwProperty;
tcf->m_pView->m_bIsNewPopup = TRUE;
tcf->m_pView->m_bIsPopUp = FALSE;
tcf->m_pView->m_bToClose = FALSE;
tcf->m_pView->m_nFilterDup = 1;
//tcf->m_pView->m_bForceResize = TRUE;
tcf->m_pView->m_nProgress = 0;
//tcf->m_pView->g_bKillAutoWin = g_bKillAutoWin;
*ppDisp = tcf->m_pView->GetApplication();
if(*ppDisp != NULL)
*Cancel = FALSE;
}catch(...){}
//CFixedHtmlView::OnNewWindow2(ppDisp, Cancel);
}
void CMyIEView::OnProgressChange(long nProgress, long nProgressMax)
{
// TODO: Add your specialized code here and/or call the base class
try{
int oldp = m_nProgress;
if(nProgressMax>0 && nProgress>=0 && nProgressMax/100>0)
{
m_nProgress = nProgress/(nProgressMax/100);
if(m_nProgress>100)
m_nProgress=100;
}
else
{
m_nProgress = -10;
}
if(m_bIsActive)
g_nPercent = m_nProgress;
//set icon
if(pmf!=NULL)
{
int nIcon = m_nProgress/34+1;
int oi = m_nOldIcon;
if(m_nProgress<0)
nIcon=-1;
if((m_nProgress>=0 && nIcon != oi) || m_nProgress<0)
{
int nTabID;
nTabID = pmf->FindTab((CChildFrame*)GetParentFrame());
if(m_nProgress>=0 && nIcon != oi)
pmf->SetTabIcon( nIcon, nTabID, this );
else if(m_nProgress<0)
{
if(((CChildFrame*)GetParentFrame())->m_bLock)
pmf->SetTabIcon( TI_LOCK, nTabID, this );
else if(((CChildFrame*)GetParentFrame())->m_bProtect)
pmf->SetTabIcon( TI_PROTECT, nTabID, this );
else
{
if(!m_bIsActive)
{
if (m_nOldIcon!=TI_0 && nProgress==0 && nProgressMax==0 && m_lpszUrl != "about:blank")//3.3.6
pmf->SetTabIcon( TI_100, nTabID, this );
}
else
{
if (m_nOldIcon!=TI_0)
pmf->SetTabIcon( TI_NO, nTabID, this );
}
}
}
//update tab bar
if(m_nProgress*oldp<=0 && oi*m_nOldIcon<=0 && m_nOldIcon != oi && pmf->m_nTabStyle==2)
pmf->PostMessage(WM_UPDATE_TAB);
//complete
if (nProgress==0 && nProgressMax==0)
{
CChildFrame* tcf = (CChildFrame*)pmf->MDIGetActive();
if (tcf && pmf->m_nState)
{
if (tcf->m_pView->m_lpszUrl == "about:blank" &&
tcf == (CChildFrame*)GetParentFrame() )
{
pmf->m_wndAddress->SetFocus();
}
else
{
CWnd* pWnd = GetFocus();
if ( pWnd == (CWnd*)(pmf->m_wndAddress->GetEditCtrl()) || pWnd == (CWnd*)(pmf->m_wndSearch->GetEditCtrl()) )
;//do nothing
else if (IsTopParentActive())
tcf->ViewSetFocus();
}
}
//run internal plugin,must place here, for that refresh not get ondocumentcomplete
if (m_nOldIcon!=TI_0)// && m_lpszUrl!="about:blank")
{
if (pmf->m_bUseFlyingFilter)
pmf->RunKillFlying((CChildFrame*)GetParentFrame());
if (pmf->m_bKillBlank && pmf->m_bUseUrlFilter)
pmf->RunKillBlank((CChildFrame*)GetParentFrame());
}
}
}
}
}catch(...){}
//CFixedHtmlView::OnProgressChange(nProgress, nProgressMax);
}
void CMyIEView::OnEditCopy()
{
// TODO: Add your command handler code here
ExecWB(OLECMDID_COPY, OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL);
}
void CMyIEView::OnEditCut()
{
// TODO: Add your command handler code here
ExecWB(OLECMDID_CUT, OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL);
}
void CMyIEView::OnEditFind()
{
// TODO: Add your command handler code here
pmf->ExecCmdTarget(HTMLID_FIND, this);
}
void CMyIEView::OnEditPaste()
{
// TODO: Add your command handler code here
ExecWB(OLECMDID_PASTE, OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL);
}
void CMyIEView::OnEditSelectAll()
{
// TODO: Add your command handler code here
ExecWB(OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL);
}
void CMyIEView::OnStatusTextChange(LPCTSTR lpszText)
{
// TODO: Add your specialized code here and/or call the base class
try{
if(m_bIsActive && pmf!=NULL)
{
if(g_bDisScrollText && lpszText!=NULL && strlen(lpszText)!=0)
{
char* pdes = strstr(lpszText, "about:");
if(pdes!=lpszText)
{
pdes = strstr(lpszText, "://");
if(pdes == NULL)
{
pdes = strstr(lpszText, "mailto:");
if(pdes == NULL)
{
pdes = strstr(lpszText, "javascript:");
}
}
}
int pos =0;
if(pdes != NULL)
{
pos = pdes - lpszText;
}
if(strncmp(lpszText,"Shortcut", 8)!=0 && strstr(lpszText, "的快捷方式")==NULL && strstr(lpszText, "地址已")==NULL && strcmp(lpszText, "Done")!=0&& (pdes==NULL || pos>10 )
&& strncmp(lpszText, "正在", 4)!=0 && strncmp(lpszText, "完成", 4)!=0 && strncmp(lpszText, "完毕", 4)!=0 && strstr(lpszText, "项剩余")==NULL
&& strncmp(lpszText, "Wait", 4)!=0 && strncmp(lpszText, "Start", 5)!=0 && strncmp(lpszText, "Open", 4)!=0 && strncmp(lpszText, "Connect", 7)!=0 && strncmp(lpszText,"Find",4)!=0 && strncmp(lpszText, "download", 8)!=0 && strncmp(lpszText, "Web", 3)!=0 && strstr(lpszText, "remain")==NULL)
return;
}
if( !( pmf->m_bStatusBlank && lpszText!=NULL && strlen(lpszText)==0))
pmf->SetMessageText(lpszText);
if(strlen(lpszText)==0)
pmf->m_bStatusBlank = TRUE;
else
pmf->m_bStatusBlank = FALSE;
}
}catch(...){}
}
BOOL CMyIEView::OnAmbientProperty(COleControlSite* pSite, DISPID dispid, VARIANT* pvar)
{
// TODO: Add your specialized code here and/or call the base class
if (dispid == DISPID_AMBIENT_DLCONTROL)
{
pvar->vt = VT_I4;
pvar->lVal = m_dwProperty;
if (pmf->m_bDisDownActivex)
pvar->lVal |= DLCTL_NO_DLACTIVEXCTLS;
return TRUE;
}
return CFixedHtmlView::OnAmbientProperty(pSite, dispid, pvar);
}
void CMyIEView::OnOptionsLoadimage()
{
// TODO: Add your command handler code here
m_dwProperty ^= DLCTL_DLIMAGES;
ChangeProperty();
if (!PRESS_CTRL)
PowerRefresh();
}
void CMyIEView::OnUpdateOptions(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
try{
switch (pCmdUI->m_nID)
{
case ID_OPTIONS_LOADIMAGE:
pmf->ToolBarSetCheck(pCmdUI, (m_dwProperty&DLCTL_DLIMAGES)!=0);
break;
case ID_OPTIONS_LOADVIDEOS:
if(m_dwProperty&DLCTL_VIDEOS)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
break;
case ID_OPTIONS_LOADSOUNDS:
if(m_dwProperty&DLCTL_BGSOUNDS)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
break;
case ID_OPTIONS_ALLOWSCRIPTS:
if(m_dwProperty&DLCTL_NO_SCRIPTS)
pCmdUI->SetCheck(0);
else
pCmdUI->SetCheck(1);
break;
case ID_OPTIONS_ALLOWJAVAAPPLET:
if(m_dwProperty&DLCTL_NO_JAVA)
pCmdUI->SetCheck(0);
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -