My application supports the IE (InternetExplorer) browser. When the back/forward buttons are clicked and there is nothing to go back or forward to, Webbrowser.GoBack() and Webbrowser.GoForward() are causing a crash.
Is there any way to know if I can go back before I actually call GoBack()? I took a look at the CWebBrowser2 class functions, but I couldn't find anything as such.
Is there any API to help on this, or any alternative approach to handle this?
Per the
IWebBrowser2::GoBack()documentation:And likewise in the
IWebBrowser2::GoForwarddocumentation:And per this discussion thread:
So, use the browser's
CSC_NAVIGATE...state changes to know when it is safe to callGoBack()/GoForward()`. These are the same events that IE uses to enable/disable its own Back/Forward UI toolbar buttons.