CHistoryObj* CPICDoloDoc::AddURLToHistory (const CString& strTitle, const CString& strURL) { ASSERT (m_arHistory.GetSize () <= HISTORY_LEN); for (int i = 0; i < m_arHistory.GetSize (); i ++) { CHistoryObj* pObj = m_arHistory [i]; ASSERT (pObj != NULL); if (pObj && pObj->GetTitle () == strTitle && pObj->GetURL () == strURL) { return pObj; } } if (m_arHistory.GetSize () == HISTORY_LEN) { delete m_arHistory [0]; m_arHistory.RemoveAt (0); } CHistoryObj* pObj = new CHistoryObj (strTitle, strURL, FIRST_HISTORY_COMMAND + (UINT)m_arHistory.GetSize ()); m_arHistory.InsertAt (0, pObj); m_iHistoryOffset = 0; return pObj; }
///////////////////////////////////////////////////////////////////////////// // CBCGPIE7DemoView message handlers // these are all simple one-liners to do simple controlling of the browser void CBCGPIE7DemoView::OnGoBack() { CBCGPIE7DemoDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); CHistoryObj* pHistoryObj = pDoc->GoBack (); if (pHistoryObj != NULL) { NavigateB (pHistoryObj->GetURL (), 0, NULL); } }
void CIEDemoView::OnGoForward() { // GoForward(); CIEDemoDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); CHistoryObj* pHistoryObj = pDoc->GoForward (); if (pHistoryObj != NULL) { Navigate2 (pHistoryObj->GetURL (), 0, NULL); } }
void CMainFrame::OnHistory(UINT nID) { CBCGPIE7DemoView* pView = DYNAMIC_DOWNCAST(CBCGPIE7DemoView, GetActiveHTML ()); if (pView != NULL) { CBCGPIE7DemoDoc* pDoc = pView->GetDocument(); ASSERT_VALID(pDoc); CHistoryObj* pObj = pDoc->Go (nID); ASSERT (pObj != NULL); Navigate (pObj->GetURL ()); } }
//**************************************************************************************** CHistoryObj* CPICDoloDoc::Go (UINT uiCmd) { for (int i = 0; i < m_arHistory.GetSize (); i ++) { CHistoryObj* pObj = m_arHistory [i]; ASSERT (pObj != NULL); if (pObj && pObj->GetCommand () == uiCmd) { m_arHistory.RemoveAt (i); m_arHistory.Add (pObj); m_iHistoryOffset = 0; return pObj; } } return NULL; }
BOOL CMainFrame::OnShowPopupMenu (CBCGPPopupMenu* pMenuPopup) { CBCGPMDIFrameWnd::OnShowPopupMenu (pMenuPopup); if (pMenuPopup == NULL) { return TRUE; } CBCGPPopupMenuBar* pMenuBar = pMenuPopup->GetMenuBar (); ASSERT_VALID (pMenuBar); for (int i = 0; i < pMenuBar->GetCount (); i ++) { CBCGPToolbarButton* pButton = pMenuBar->GetButton (i); ASSERT_VALID (pButton); if (pButton->m_nID == ID_FAVORITES_DUMMY) { pMenuBar->ImportFromMenu (m_menuFavotites); pMenuPopup->SetMaxWidth (300); return TRUE; } if (pButton->m_nID == ID_VIEW_HISTORY) { CMenu menuHistory; menuHistory.LoadMenu (IDR_HISTORY_POPUP); CMenu* subMenu = menuHistory.GetSubMenu (0); ASSERT_VALID (subMenu); CBCGPIE7DemoView* pView = DYNAMIC_DOWNCAST(CBCGPIE7DemoView, GetActiveHTML ()); if (pView != NULL) { CBCGPIE7DemoDoc* pDoc = pView->GetDocument (); if (pDoc != NULL) { _T_HistotyList lst; int index = 0; POSITION pos = NULL; pDoc->GetBackList (lst); for (pos = lst.GetHeadPosition (); pos != NULL;) { CHistoryObj* pObj = lst.GetNext (pos); ASSERT (pObj != NULL); subMenu->InsertMenu (index, MF_STRING | MF_BYPOSITION, pObj->GetCommand (), pObj->GetTitle ()); index++; } pDoc->GetFrwdList (lst); for (pos = lst.GetHeadPosition (); pos != NULL;) { CHistoryObj* pObj = lst.GetNext (pos); ASSERT (pObj != NULL); subMenu->InsertMenu (index, MF_STRING | MF_BYPOSITION, pObj->GetCommand (), pObj->GetTitle ()); index++; } if (index > 0) { subMenu->InsertMenu (index, MF_SEPARATOR | MF_BYPOSITION, 0, (LPCTSTR)NULL); } } } pMenuBar->ImportFromMenu (subMenu->GetSafeHmenu ()); return TRUE; } } return TRUE; }