Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

history in IE Object

Hi all,
   I use CHtmlView in my app and I can go back and go forward in history with  GoBack() and GoForward() funtion.  But I have some question How can I know the end of history
so I can disable the back button or forward button.

Does anyone has any idea please suggest me.?
0
eakkung
Asked:
eakkung
  • 3
  • 2
  • 2
1 Solution
 
Roshan DavisCommented:
Try

IOmHistory Interface
0
 
eakkungAuthor Commented:
do you have any sample? I don't know how to use it.
0
 
Roshan DavisCommented:
Find "HOWTO: Disable the Default Pop-up Menu for CHtmlView" in MSDN, you can find how to get IWebBrowser2.

From IWebBrowser2, yu will get the IOmHistory.

Good Luck
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
eakkungAuthor Commented:
I used  code like this to get interface
 
     IOmHistory* m_phistObj;
     HRESULT hr1 = lpUnk->QueryInterface(IID_IOmHistory, (void**) &m_phistObj);

but I can not get it. Do you have any idea to suggest me.

I upgrage point to 250
0
 
Roshan DavisCommented:
Please wait

I'm looking into the problem..
0
 
JaguarWinnerCommented:
use CHtmlView::OnCommandStateChange(long nCommand,BOOL bEnable) message handle,program like this:

CMyView::OnCommandStateChange(long nCommand,BOOL bEnable)
{
   switch(nCommand)
   {
   case CSC_NAVIGATEBACK:
      BackButton.Enable=bEnable;
      break;
   case CSC_NAVIGATEFORWARD:
      ForwardButton.Enable=bEnable;
      break;
   default:
      break;
   }
}
0
 
JaguarWinnerCommented:
In addition,you could disable or enable the toolbar's button with this code:

//in the Message Map for CMainFrame
ON_UPDATE_COMMAND_UI(ID_GO_BACK, OnUpdateGoBack)
ON_UPDATE_COMMAND_UI(ID_GO_FORWARD, OnUpdateGoForward)
...

//OnUpdateGoBack function
void CMainFrame::OnUpdateGoBack(CCmdUI* pCmdUI)  
{
   pCmdUI->Enable(m_bBackBtnEnabled);
}
//OnUpdateGoForward function
void CMainFrame::OnUpdateGoForward(CCmdUI* pCmdUI)  
{
   pCmdUI->Enable(m_bForwardBtnEnabled);
}

//your CHtmlView code
CMyView::OnCommandStateChange(long nCommand,BOOL bEnable)
{
  CMainFrame* pMF=(CMainFrame*)AfxGetApp()->m_pMainWnd;
  switch(nCommand)
  {
  case CSC_NAVIGATEBACK:
     pMF->m_bBackBtnEnabled=bEnable;
     break;
  case CSC_NAVIGATEFORWARD:
     pMF->m_bForwardBtnEnabled=bEnable;
     break;
  default:
     break;
  }
}
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now