HOWTO: Using Forward & Back Buttons for Web Browser ControlLast reviewed: October 31, 1997Article ID: Q163282 |
The information in this article applies to:
SUMMARYWhen hosting the Web Browser control, it may be desirable to implement Forward and Back buttons similar to those that Internet Explorer implements. One common problem that programmers face when doing this is how to know when to enable and disable the buttons.
MORE INFORMATIONThe Web Browser control supports a CommandStateChange event, which is fired whenever the Forward or Back buttons need to be enabled or disabled. The CommandStateChange event is sent with two parameters: a constant indicating the type of button (CSC_NAVIGATEFORWARD or CSC_NAVIGATEBACK), and a Boolean flag indicating whether to enable or disable the button. CSC_NAVIGATEFORWARD and CSC_NAVIGATEBACK are defined in Exdisp.h, which comes with the Internet Client SDK.
Sample Code
#include <exdisp.h> // For an MFC application the CommandStateChange event could be handled // as follows: void CBrowserDlg::OnCommandStateChangeExplorer1(long Command, BOOL Enable) { switch(Command) { case CSC_NAVIGATEFORWARD: // m_ctlForward is a CButton type m_ctlForward.EnableWindow(Enable); break; case CSC_NAVIGATEBACK: m_ctlBack.EnableWindow(Enable); break; default: break; } } // A Visual Basic application can also implement this functionality in // this manner: Private Sub WebBrowser_CommandStateChange (ByVal Command As Long, ByVal Enable As Boolean) Select Case Command Case CSC_NAVIGATEBACK Back.Enabled = Enable Case CSC_NAVIGATEFORWARD Forward.Enabled = Enable End Select End Sub Keywords : AXSDKWebBrowser kbusage Technology : kbDSupport Version : 1.0 Platform : WINDOWS Issue type : kbhowto |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |