📄 mainfrm.cpp
字号:
{ { 15, ID_VIEW_FULLSCREEN, TBSTATE_ENABLED, TBSTYLE_BUTTON , 0, 0 }, true},
{ { 14, ID_DOWNLOAD_CONTROL, TBSTATE_ENABLED, TBSTYLE_BUTTON|TBSTYLE_DROPDOWN , 0, 0 }, true},
{ { 9, ID_SETPROXY_TOOL, TBSTATE_ENABLED, TBSTYLE_BUTTON |TBSTYLE_DROPDOWN, 0, 0 }, true},
{ { 10, ID_READMAIL_TOOL, TBSTATE_ENABLED, TBSTYLE_BUTTON |TBSTYLE_DROPDOWN, 0, 0 }, true},
{ { 13, ID_SOURCECODE_VIEW, TBSTATE_ENABLED, TBSTYLE_BUTTON |TBSTYLE_DROPDOWN, 0, 0 }, true},
{ { 17, ID_FILE_OPENURL, TBSTATE_ENABLED, TBSTYLE_BUTTON ,0, 0 }, true},
{ { 19, ID_FILE_SAVE_AS, TBSTATE_ENABLED, TBSTYLE_BUTTON ,0, 0 }, true},
{ { 20, ID_VIEW_STOP_ALL, TBSTATE_ENABLED, TBSTYLE_BUTTON ,0, 0 }, true},
{ { 21, ID_VIEW_REFRESH_ALL, TBSTATE_ENABLED, TBSTYLE_BUTTON ,0, 0 }, true},
{ { 18, ID_FIND_EDIT, TBSTATE_ENABLED, TBSTYLE_BUTTON ,0, 0 }, true}
};
SetBitmaps(IDB_HOTTOOLBARSM,-1, IDB_HOTTOOLBAR, -1, ioLargeIcons);
SetButtons( sizeof( tbButtons ) / sizeof( tbButtons[ 0 ] ), tbButtons, toNoTextLabels);
}
bool CMainToolBar::HasButtonText( UINT nID )
{
switch ( nID )
{
case ID_GO_BACK:
case ID_FILE_PRINT:
case ID_GO_FORWARD:
case ID_VIEW_STOP:
case ID_VIEW_REFRESH:
case ID_GO_START_PAGE:
case ID_GO_SEARCH_THE_WEB:
case ID_FAVORITES_DROPDOWN:
case ID_FONT_DROPDOWN:
case ID_VIEW_FULLSCREEN:
return true;
default:
return false;
}
}
//////////////////////////////////////
IMPLEMENT_DYNAMIC( CLinkBar, CToolBarEx )
CLinkBar::CLinkBar()
{
}
void CLinkBar::Init()
{
// Delete old buttons
CToolBarCtrl& tbCtrl = GetToolBarCtrl();
while ( tbCtrl.DeleteButton( 0 ) );
// Load buttons from provided array
m_aButtons.RemoveAll();
CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->m_pMainWnd;
for(int i=0;i<pFrame->m_linkbarItem.GetSize();i++)
{
TBBUTTONEX tbButtons[] =
{
{ { pFrame->m_linkbarItem[i]->icon,pFrame->m_linkbarItem[i]->nID,TBSTATE_ENABLED, TBSTYLE_BUTTON, 0,0 }, true}
};
AddButton(i,*tbButtons,pFrame->m_linkbarItem[i]->strName);
}
//the linkbar item will never be used so delete it
for(i=0;i<pFrame->m_linkbarItem.GetSize();i++)
{
delete pFrame->m_linkbarItem [i];
}
pFrame->m_linkbarItem.RemoveAll();
CImageList m_ImageListSmall;
HIMAGELIST hImageList;
SHFILEINFO shFi;
hImageList=(HIMAGELIST)SHGetFileInfo("C:\\",0,&shFi,sizeof(shFi),
SHGFI_SYSICONINDEX|SHGFI_SMALLICON);
m_ImageListSmall.m_hImageList=hImageList;
//CToolBarCtrl& tbCtrl = GetToolBarCtrl();
tbCtrl.SetImageList(&m_ImageListSmall);
m_ImageListSmall.Detach();
m_eIconOptionsDefault=m_eIconOptions=ioSmallIcons;
SetCustomizeMode(FALSE);
ReloadButtons();
UpdateParentBandInfo();
//SetBitmaps( IDB_COLDTOOLBAR, IDB_HOTTOOLBAR, IDB_COLDTOOLBAR, IDB_COLDTOOLBAR, ioSmallIcons );
}
bool CLinkBar::HasButtonText( UINT nID )
{
return TRUE;
}
void CLinkBar::GetButtonTip( UINT nID, CString& strTip)
{
CMainFrame * pMainfrm=(CMainFrame *)AfxGetApp()->m_pMainWnd;
if( nID>0xe00&& nID<0xfff)
{
if((nID-0xe00)<(UINT)pMainfrm->m_astrFavoriteURLs.GetSize())
{
strTip=pMainfrm->m_astrFavoriteURLs[nID-0xe00];
}
}
}
bool CLinkBar::HasButtonTip( UINT nID )
{
return TRUE;
}
///////////////////////////////////////////////////////
typedef UINT (CALLBACK* LPFNORGFAV)(HWND, LPTSTR);
void CMainFrame::OnOrganizeFavorites()
{
// TODO: Add your command handler code here
// handle.
HMODULE hModule = ::LoadLibrary("SHDOCVW.DLL");
if (hModule == NULL)
return; // failed to load
LPFNORGFAV lpfnOrgFav =
(LPFNORGFAV)::GetProcAddress(hModule,
"DoOrganizeFavDlg");
if (lpfnOrgFav == NULL)
{
::FreeLibrary(hModule);
return;
}
TCHAR wszPathName[_MAX_PATH];
// Get the path name of the Favorites folder, since
// DoOrganizeFavDlg takes as its inputs the HWND
// of the parent window and the path name of the
// folder to display.
HRESULT hResult =
::SHGetSpecialFolderPath(GetSafeHwnd(),
wszPathName,
CSIDL_FAVORITES, TRUE);
if (FAILED(hResult))
{
::FreeLibrary(hModule);
return;
}
// Call DoOrganizeFavDlg() through the lpfnOrgFav
// function pointer.
lpfnOrgFav(GetSafeHwnd(), wszPathName);
::FreeLibrary(hModule);
RefreshFavoriteMenu();
}
void CMainFrame::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(nIDEvent==1)
AutoRefresh(m_activeonly);
CMDIFrameWndEx::OnTimer(nIDEvent);
}
void CMainFrame::OnHistory(UINT nID)
{
// CChildFrame *childfrm=(CChildFrame *)GetActiveFrame();
CBenbenBrowserView* pView = (CBenbenBrowserView*)GetbenActiveView();
ASSERT_VALID (pView);
CBenbenBrowserDoc* pDoc = pView->GetDocument();
ASSERT_VALID(pDoc);
CHistoryObj* pObj = pDoc->Go(nID);
ASSERT (pObj != NULL);
pView->Navigate2 (pObj->GetURL(),NULL,NULL);
}
void CMainFrame::PlayAnimate()
{
m_wndAnimate.Play(0, -1, -1);
}
void CMainFrame::StopAnimate()
{
m_wndAnimate.Stop();
m_wndAnimate.Seek(0);
}
void CMainFrame::OnViewLinkbar()
{
// TODO: Add your command handler code here
ShowControlBar(&m_linkbar,(m_linkbar.GetStyle() & WS_VISIBLE) == 0, FALSE);
}
void CMainFrame::OnUpdateViewLinkbar(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_linkbar.GetStyle() & WS_VISIBLE);
}
void CMainFrame::OnNorefreshView()
{
// TODO: Add your command handler code here
if(m_autorefreshtype!=0)
{
KillTimer(1);
m_autorefreshtype=0;
}
}
void CMainFrame::OnUpdateNorefreshView(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_autorefreshtype==0);
}
void CMainFrame::AutoRefresh(bool type)
{
try
{
CChildFrame *pchild=(CChildFrame *)GetActiveFrame();
if(!pchild)
return;
CBenbenBrowserView *pview=(CBenbenBrowserView *)pchild->GetActiveView();
if(type && pview)//type=1 -->current tab only type=0-->all tabs
{
pview->Refresh();
return;
}
while(pview)
{
pview->Refresh();
pchild=(CChildFrame *)pchild->GetNextWindow();
if(!pchild)
break;
pview=(CBenbenBrowserView *)pchild->GetActiveView();
}
}
catch(...)
{
}
}
void CMainFrame::OnAutorefresh5View()
{
// TODO: Add your command handler code here
if(m_autorefreshtype!=1)
{
KillTimer(1);
m_autorefreshtype=1;
SetTimer(1,5000,NULL);
}
}
void CMainFrame::OnUpdateAutorefresh5View(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_autorefreshtype==1);
}
void CMainFrame::OnAutorefresh15View()
{
// TODO: Add your command handler code here
if(m_autorefreshtype!=2)
{
KillTimer(1);
m_autorefreshtype=2;
SetTimer(1,15000,NULL);
}
}
void CMainFrame::OnUpdateAutorefresh15View(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_autorefreshtype==2);
}
void CMainFrame::OnAutorefresh30View()
{
// TODO: Add your command handler code here
if(m_autorefreshtype!=3)
{
KillTimer(1);
m_autorefreshtype=3;
SetTimer(1,30000,NULL);
}
}
void CMainFrame::OnUpdateAutorefresh30View(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_autorefreshtype==3);
}
void CMainFrame::OnAutorefresh1mView()
{
// TODO: Add your command handler code here
if(m_autorefreshtype!=4)
{
KillTimer(1);
m_autorefreshtype=4;
SetTimer(1,60000,NULL);
}
}
void CMainFrame::OnUpdateAutorefresh1mView(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_autorefreshtype==4);
}
void CMainFrame::OnAutorefresh5mView()
{
// TODO: Add your command handler code here
if(m_autorefreshtype!=5)
{
KillTimer(1);
m_autorefreshtype=5;
SetTimer(1,300000,NULL);
}
}
void CMainFrame::OnUpdateAutorefresh5mView(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_autorefreshtype==5);
}
void CMainFrame::OnAutorefresh10mView()
{
// TODO: Add your command handler code here
if(m_autorefreshtype!=6)
{
KillTimer(1);
m_autorefreshtype=6;
SetTimer(1,600000,NULL);
}
}
void CMainFrame::OnUpdateAutorefresh10mView(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_autorefreshtype==6);
}
void CMainFrame::OnAutorefreshonlyView()
{
// TODO: Add your command handler code here
m_activeonly=!m_activeonly;
}
void CMainFrame::OnUpdateAutorefreshonlyView(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_activeonly);
}
void CMainFrame::GetFileIcon(CString filename, int &icon)
{
try
{
CString str=filename;
if(str.Right(1)!="\\")
str+="\\";
SHFILEINFO shFi;
if(!SHGetFileInfo(str,0,&shFi,sizeof(shFi),SHGFI_ICON|SHGFI_SMALLICON|SHGFI_DISPLAYNAME))
{
AfxMessageBox("111");
return;
}
icon=shFi.iIcon;
DestroyIcon(shFi.hIcon);
}
catch(...)
{
}
return ;
}
void CMainFrame::OnDownloadimageTool()
{
// TODO: Add your command handler code here
m_showimage=!m_showimage;
HKEY hKey;
if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Internet Explorer\\Main"), &hKey) != ERROR_SUCCESS)
{
TRACE0("multimedia setting not found\n");
return ;
}
if(m_showimage)
RegSetValueEx(hKey,_T("Display Inline Images"),0,REG_SZ,(LPBYTE)"yes",3);
else
RegSetValueEx(hKey,_T("Display Inline Images"),0,REG_SZ,(LPBYTE)"no",2);
RegCloseKey(hKey);
m_dwdownloadProperty^=DLCTL_DLIMAGES;
ChangeDLProperty();
return ;
}
void CMainFrame::OnUpdateDownloadimageTool(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_dwdownloadProperty&DLCTL_DLIMAGES);
}
void CMainFrame::OnDownloadanimationTool()
{
// TODO: Add your command handler code here
m_showanimation=!m_showanimation;
HKEY hKey;
if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Internet Explorer\\Main"), &hKey) != ERROR_SUCCESS)
{
TRACE0("multimedia setting not found\n");
return ;
}
if(m_showanimation)
{
RegSetValueEx(hKey,_T("Play_Animations"),0,REG_SZ,(LPBYTE)"yes",3);
}
else
{
RegSetValueEx(hKey,_T("Play_Animations"),0,REG_SZ,(LPBYTE)"no",2);
}
RegCloseKey(hKey);
//dwProperty ^= DLCTL_DLIMAGES;
return ;
}
void CMainFrame::OnUpdateDownloadanimationTool(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_showanimation);
}
void CMainFrame::OnDownloadsoundTool()
{
// TODO: Add your command handler code here
m_showsound=!m_showsound;
HKEY hKey;
if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Internet Explorer\\Main"), &hKey) != ERROR_SUCCESS)
{
TRACE0("multimedia setting not found\n");
return ;
}
if(m_showsound)
RegSetValueEx(hKey,_T("Play_Background_Sounds"),0,REG_SZ,(LPBYTE)"yes",3);
else
RegSetValueEx(hKey,_T("Play_Background_Sounds"),0,REG_SZ,(LPBYTE)"no",2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -