📄 myieview.cpp
字号:
pCmdUI->SetCheck(1);
break;
case ID_OPTIONS_ALLOWACTIVEX:
if(m_dwProperty&DLCTL_NO_RUNACTIVEXCTLS)
pCmdUI->SetCheck(0);
else
pCmdUI->SetCheck(1);
break;
}
}catch(...){}
}
void CMyIEView::OnOptionsAllowscripts()
{
// TODO: Add your command handler code here
m_dwProperty ^= DLCTL_NO_SCRIPTS;
ChangeProperty();
if (!PRESS_CTRL)
PowerRefresh();
}
void CMyIEView::OnOptionsLoadsounds()
{
// TODO: Add your command handler code here
m_dwProperty ^= DLCTL_BGSOUNDS;
ChangeProperty();
if (!PRESS_CTRL)
PowerRefresh();
}
void CMyIEView::OnOptionsLoadvideos()
{
// TODO: Add your command handler code here
m_dwProperty ^= DLCTL_VIDEOS;
ChangeProperty();
if (!PRESS_CTRL)
PowerRefresh();
}
void CMyIEView::OnOptionsUseWebp()
{
// TODO: Add your command handler code here
if(m_bEnWebProxy)
m_bEnWebProxy = FALSE;
else
{
m_bEnWebProxy = TRUE;
//auto refresh
if (m_strWebProxy.IsEmpty())
{
if (!pmf->m_strDefaultWebProxy.IsEmpty())
m_strWebProxy = pmf->m_strDefaultWebProxy;
else
{
m_bEnWebProxy = FALSE;
MSGBOX(IDS_NO_WEB_PROXY);
return;
}
}
if(!m_lpszUrl.IsEmpty() && m_lpszUrl!="about:blank")
{
ToNavigate(m_lpszUrl, 0, NULL, NULL, NULL, 0, TRUE);
}
}
}
void CMyIEView::OnUpdateOptionsUseWebp(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
try
{
pmf->ToolBarSetCheck(pCmdUI, m_bEnWebProxy);
}catch(...){}
}
void CMyIEView::OnOptionsAllowactivex()
{
// TODO: Add your command handler code here
m_dwProperty ^= DLCTL_NO_RUNACTIVEXCTLS;
ChangeProperty();
if (!PRESS_CTRL)
PowerRefresh();
}
void CMyIEView::OnOptionsAllowjavaapplet()
{
// TODO: Add your command handler code here
m_dwProperty ^= DLCTL_NO_JAVA;
ChangeProperty();
if (!PRESS_CTRL)
PowerRefresh();
}
void CMyIEView::OnCommandStateChange(long nCommand, BOOL bEnable)
{
// TODO: Add your specialized code here and/or call the base class
if(nCommand == 2)
m_bBack = bEnable;
else if(nCommand == 1)
m_bForward = bEnable;
// CFixedHtmlView::OnCommandStateChange(nCommand, bEnable);
}
void CMyIEView::OnUpdateGoBack(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
try{
pCmdUI->Enable(m_bBack);
}catch(...){}
}
void CMyIEView::OnUpdateGoForward(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
try{
pCmdUI->Enable(m_bForward);
}catch(...){}
}
void ResizeSibling(CMyIEView* pvw)
{
try{
g_bMax = 0;
CChildFrame* tcf;
CRect oldrect,rect;
if(pmf!=NULL)
{
int n = pmf->m_wndTab.GetItemCount();
TCITEM TabCtrlItem;
TabCtrlItem.mask = TCIF_PARAM;
for(int i=n-1;i>=0;i--)
{
pmf->m_wndTab.GetItem(i, &TabCtrlItem);
tcf = ((CChildFrame*)TabCtrlItem.lParam);
if(tcf != NULL && tcf->m_pView!=NULL)
{
if(tcf->m_pView != pvw)
{
tcf->GetClientRect(&rect);
tcf->m_pView->m_wndBrowser.GetWindowRect(&oldrect);
tcf->m_pView->ScreenToClient(&oldrect);
if(oldrect.left != -BORDER && oldrect.top != -BORDER)
{
try{
tcf->m_pView->m_wndBrowser.MoveWindow(-2,-2, rect.Width()+BORDER+BORDER, rect.Height()+BORDER+BORDER);
}catch(...){}
}
else
{
try{
if(oldrect.Width()!=rect.Width()+BORDER+BORDER && rect.Width()!=0)
tcf->m_pView->SetWidth (rect.Width()+BORDER+BORDER);
if(oldrect.Height()!=rect.Height()+BORDER+BORDER && rect.Height()!=0)
tcf->m_pView->SetHeight (rect.Height()+BORDER+BORDER);
}catch(...){}
}
}
}
}
}
}catch(...){}
}
void CMyIEView::OnSize(UINT nType, int cx, int cy)
{
try
{
if(g_bMax==1)
{
if(GetParentFrame()->IsZoomed())
{
CRect oldrect;
m_wndBrowser.GetWindowRect(&oldrect);
ScreenToClient(&oldrect);
if(oldrect.left != -BORDER && oldrect.top != -BORDER)
{
try{
m_wndBrowser.MoveWindow(-2,-2, cx+BORDER+BORDER, cy+BORDER+BORDER);
}catch(...){}
}
else
{
try{
if(oldrect.Width()!=cx+BORDER+BORDER )
SetWidth (cx+BORDER+BORDER);
if(oldrect.Height()!=cy+BORDER+BORDER)
SetHeight (cy+BORDER+BORDER);
}catch(...){}
}
}
}
else
{
CRect oldrect;
m_wndBrowser.GetWindowRect(&oldrect);
ScreenToClient(&oldrect);
if(oldrect.left != -BORDER && oldrect.top != -BORDER)
{
try{
m_wndBrowser.MoveWindow(-2,-2, cx+BORDER+BORDER, cy+BORDER+BORDER);
}catch(...){}
}
else
{
try{
if(oldrect.Width()!=cx+BORDER+BORDER && cx!=0)
SetWidth (cx+BORDER+BORDER);
if(oldrect.Height()!=cy+BORDER+BORDER && cy!=0)
SetHeight (cy+BORDER+BORDER);
}catch(...){}
}
if(GetParentFrame()->GetStyle() & WS_MAXIMIZE)
g_bMax = 1;
}
//size other views
if(g_bMax == 3)
ResizeSibling(this);
}catch(...){}
}
void CMyIEView::OnUpdateViewFonts(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(pCmdUI->m_nID==ID_VIEW_FONTS_LARGEST+m_nFontSize)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CMyIEView::ToNavigate(LPCTSTR URL, DWORD dwFlags, LPCTSTR lpszTargetFrameName, LPCTSTR lpszHeaders, LPVOID lpvPostData, DWORD dwPostDataLen, BOOL bOnlyRefresh)
{
try{
CString str = URL;
CString str2 = URL;
m_lpszUrl=URL;
m_bFirst = TRUE;
if(m_bEnWebProxy)
{
if(m_strWebProxy.IsEmpty() && pmf!=NULL)
m_strWebProxy = pmf->m_strDefaultWebProxy;
if((str.Left(4)=="http" || str.Left(4)=="www.") && str.Find(m_strWebProxy)<0)
{
if(str.Left(4)=="www.")
str2 = "http://" + str;
if(m_strWebProxy.Find("%s")>0)
{
str2.Replace(":", "%3A");
str2.Replace("/", "%2F");
str = m_strWebProxy;
str.Replace("%s", str2);
}
else if(m_strWebProxy.Find("%S")>0)
{
str = m_strWebProxy;
str.Replace("%S", str2);
}
else
str = m_strWebProxy+str2;
Navigate2(str, dwFlags, lpszTargetFrameName, lpszHeaders,lpvPostData, dwPostDataLen);
}
else if(!bOnlyRefresh)
Navigate2(str, dwFlags, lpszTargetFrameName, lpszHeaders,lpvPostData, dwPostDataLen);
}
else if(!bOnlyRefresh)
Navigate2(str, dwFlags, lpszTargetFrameName, lpszHeaders,lpvPostData, dwPostDataLen);
}catch(...){}
m_nProgress = -1;
}
void CMyIEView::OnParentNotify(UINT message, LPARAM lParam)
{
CFixedHtmlView::OnParentNotify(message, lParam);
// TODO: Add your message handler code here
try{
CChildFrame* tcf = (CChildFrame*)GetParentFrame();
//
pmf->m_ptMouseDown.x = LOWORD((DWORD)lParam);
pmf->m_ptMouseDown.y = HIWORD((DWORD)lParam);
//
if (message==WM_LBUTTONDOWN && pmf->m_nLButtonDown)
{
if (MouseAction(pmf->m_nLButtonDown))
{
if (pmf->m_nMButtonDown>=ID_OPEN_LINK && pmf->m_nMButtonDown<=ID_OPEN_LINK_DEACTIVE)
{
//for that simu as shift+click
QueryPerformanceCounter(&m_tLastClick);
m_bLClick = TRUE;
}
return;
}
}
else if (message==WM_RBUTTONDOWN && pmf->m_nRButtonDown)
{
if (MouseAction(pmf->m_nRButtonDown))
{
if (pmf->m_nMButtonDown>=ID_OPEN_LINK && pmf->m_nMButtonDown<=ID_OPEN_LINK_DEACTIVE)
{
//for that simu as shift+click
QueryPerformanceCounter(&m_tLastClick);
m_bLClick = TRUE;
}
SetCapture();
m_bIsCapture = TRUE;
pmf->m_bPopRightMenu=FALSE;
return;
}
}
//
if((message == WM_LBUTTONDOWN || message == WM_RBUTTONDOWN) && (g_bLinkInNewWindow || tcf->m_bLock || g_bKillAutoWin) )
{
if(message == WM_LBUTTONDOWN )
{
QueryPerformanceCounter(&m_tLastClick);
m_bRClick = FALSE;
m_bLClick = TRUE;
m_ptLClick.x = LOWORD((DWORD)lParam);
m_ptLClick.y = HIWORD((DWORD)lParam);
}
else if(message == WM_RBUTTONDOWN )
{
QueryPerformanceCounter(&m_tLastRClick);
m_bRClick = TRUE;
m_bLClick = FALSE;
}
else
m_bRClick = FALSE;
}
if ( (message==WM_RBUTTONDOWN) &&
(pmf->m_bRMouseDrag || pmf->m_bRMouseGesture)
)
{
SetCapture();
m_bIsCapture = TRUE;
//m_bRClick = FALSE;
m_ptRClick.x = LOWORD((DWORD)lParam);
m_ptRClick.y = HIWORD((DWORD)lParam);
m_ptPrev = m_ptRClick;
g_nGestureHead = 0;
g_nGestureTail = 0;
pmf->m_bPopRightMenu=TRUE;
}
}catch(...){}
}
//scroll horizontal page
void CMyIEView::WBScrollHPage(int bLeft)
{
CMyIEView* pvw = this;
if(pvw->m_bToClose)
return;
LPDISPATCH pDisp = NULL;
IHTMLDocument2 *pHTMLDoc = NULL;
IHTMLWindow2 *pHTMLWnd = NULL;
try{
pDisp = pvw->GetHtmlDocument();
if( pDisp )
{
if (SUCCEEDED(pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pHTMLDoc)))
{
if(SUCCEEDED(pHTMLDoc->get_parentWindow( &pHTMLWnd )))
{
CRect rect;
pvw->m_wndBrowser.GetWindowRect(&rect);
if (bLeft)
pHTMLWnd->scrollBy(-(long)(rect.Width()*0.87),0);
else
pHTMLWnd->scrollBy((long)(rect.Width()*0.87),0);
}
}
}
}catch(...){}
try{
if(pHTMLWnd!=NULL) pHTMLWnd->Release();
if(pHTMLDoc!=NULL) pHTMLDoc->Release();
if(pDisp!=NULL) pDisp->Release();
}catch(...){}
}
void CMyIEView::WBScrollBy(long xpos,long ypos)
{
CMyIEView* pvw = this;
if(pvw->m_bToClose)
return;
LPDISPATCH pDisp = NULL;
IHTMLDocument2 *pHTMLDoc = NULL;
IHTMLWindow2 *pHTMLWnd = NULL;
try{
pDisp = pvw->GetHtmlDocument();
if( pDisp )
{
if (SUCCEEDED(pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pHTMLDoc)))
{
if(SUCCEEDED(pHTMLDoc->get_parentWindow( &pHTMLWnd )))
pHTMLWnd->scrollBy(xpos,ypos);
}
}
}catch(...){}
try{
if(pHTMLWnd!=NULL) pHTMLWnd->Release();
if(pHTMLDoc!=NULL) pHTMLDoc->Release();
if(pDisp!=NULL) pDisp->Release();
}catch(...){}
}
void CMyIEView::OnClose()
{
// TODO: Add your message handler code here and/or call default
try{
CFixedHtmlView::OnClose();
}catch(...){}
}
void CMyIEView::ChangeProperty()
{
try{
m_dwPropertyDefault = m_dwProperty;
IOleControl* poc;
LPDISPATCH pDisp = GetHtmlDocument();
if(pDisp != NULL)
{
if(SUCCEEDED(pDisp->QueryInterface(IID_IOleControl, (void**)&poc)))
{
poc->OnAmbientPropertyChange(DISPID_AMBIENT_DLCONTROL);
poc->Release();
}
pDisp->Release();
}
}catch(...){}
}
void CMyIEView::OnNavigateComplete2(LPCTSTR lpszURL)
{
try
{
CString strUrl;
CChildFrame* tcf = ((CChildFrame*)GetParentFrame());
GetLocationURL(strUrl);
if(!m_bToClose && ((m_bIsPopUp && m_bIsNewPopup) || (tcf!=NULL && !tcf->IsWindowVisible())) && !strUrl.IsEmpty())
{
CString url2 = strUrl.Right(m_strPossibleURL.GetLength()+13);
if((pmf->IsWindowVisible() && tcf!=NULL && !tcf->IsWindowVisible()) || url2 == "navcancl.htm#" + m_strPossibleURL /*for IE 5*/|| strUrl == "about:NavigationCanceled" /*for IE4*/ || strUrl==m_strPossibleURL)
{
if(tcf!=NULL)
{
tcf->PostMessage(WM_CLOSE);
m_bToClose = TRUE;
}
m_bIsPopUp = FALSE;
}
}
//
try
{
//security flag
if(!m_bToClose)
{
g_bVerbose = TRUE;
if(strUrl.Left(5)=="https")
{
LPDISPATCH pDisp = NULL;
IHTMLDocument2 *pHTMLDoc = NULL;
BSTR p;
try
{
pDisp = GetHtmlDocument();
if( pDisp )
pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pHTMLDoc);
else
m_bIsSecure = FALSE;
if(pHTMLDoc)
{
if(SUCCEEDED(pHTMLDoc->get_protocol( &p )))
{
CString s(p);
if(s=="HyperText Transfer Protocol with Privacy" || s.Find("私人验证")>0 || s.Find("玂盞")>0)
m_bIsSecure = TRUE;
else
m_bIsSecure = FALSE;
SysFreeString(p);
}
}
if(m_bIsActive && pmf!=NULL)
pmf->m_bIsSecure = m_bIsSecure;
}catch(...){}
try
{
if(pHTMLDoc!=NULL)
pHTMLDoc->Release();
if(pDisp!=NULL)
pDisp->Release();
}catch(...){}
}
}
}catch(...){}
}catch(...){}
}
void CMyIEView::OnFileSaveAs()
{
// TODO: Add your command handler code here
ExecWB(OLECMDID_SAVEAS, OLECMDEXECOPT_DODEFAULT,
NULL, NULL);
}
void CMyIEView::OnFileSavehtml()
{
// TODO: Add your command handler code here
ExecWB(OLECMDID_SAVEAS, OLECMDEXECOPT_DONTPROMPTUSER,
NULL, NULL);
}
void CMyIEView::OnFilePrintSetup()
{
// TODO: Add your command handler code here
ExecCommand(OLECMDID_PAGESETUP);
}
void CMyIEView::OnFileProperty()
{
// TODO: Add your command handler code here
ExecCommand(OLECMDID_PROPERTIES);
}
void CMyIEView::ExecCommand(DWORD nCmdID)
{
LPOLECOMMANDTARGET lpTarget = NULL;
LPDISPATCH lpDisp = GetHtmlDocument();
if (lpDisp != NULL)
{
// the control will handle all printing UI
if (SUCCEEDED(lpDisp->QueryInterface(IID_IOleCommandTarget,
(LPVOID*) &lpTarget)))
{
lpTarget->Exec(NULL, nCmdID, 0, NULL, NULL);
lpTarget->Release();
}
lpDisp->Release();
}
}
void CMyIEView::OnRButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
try{
if(m_bIsCapture)
{
int i =0;
m_bIsCapture = FALSE;
ReleaseCapture();
//if have right button down action, then not pop menu
if (pmf->m_nRButtonDown!=0)
goto _PopRightMenu;
//if mouse drag and not move then need pop menu
if (pmf->m_bRMouseDrag)
goto _PopRightMenu;
g_cGestureString[0]= '\0';
while(g_nGestureTail != g_nGestureHead)
{
g_cGestureString[i] = g_cGestureStack[g_nGestureHead];
i++;
g_cGestureString[i] = '\0';
g_nGestureHead = (g_nGestureHead +1)%MG_LEN;
}
if(i>0)
{
int command = pmf->m_GestureList.GetCmdFromName(g_cGestureString);
if (command)
MouseAction(command);
}
_PopRightMenu:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -