别总是急着找MS的bug嘛!先仔细读读MSDN吧:Command: A long integer specifying the identifier of the command that changed. 
         It can be one of the following constants or values.    
         Constant Value Meaning  
         CSC_UPDATECOMMANDS -1 The enabled state of a toolbar button may have changed; the Enable parameter should be ignored. 
         CSC_NAVIGATEFORWARD 1 The enabled state of the Forward button has changed. 
         CSC_NAVIGATEBACK 3 The enabled state of the Back button has changed. 
 
Enable:  A Boolean value that is TRUE if the command is enabled, or FALSE if not. 所以,command的值的确不可能是2,比如,你要知道什么时候不能再Forward了,那就是:(command == 1 && enable == false);
而不能Back则是: (command == 3 && enable == false);

解决方案 »

  1.   

    我在VS.NET Beta2中文版的VC#中反复测试过,当用GoBack方法时,根本不能返回command==3和enable==false。
    它只是不断返回command=1和enable=true。再次说明是在VS.NET Beta2中文版的VC#中。同时在对象浏览器中
    查看过,当command==2 && enable==false时方法GoBack才不能。请各位多多发表意见。谢谢!!
      

  2.   

    sorry,确实是MSDN有错误:
    [EXDISP.H]
    typedef /* [helpstring][uuid] */ 
    enum CommandStateChangeConstants
        { CSC_UPDATECOMMANDS = 0xffffffff,
    CSC_NAVIGATEFORWARD = 0x1,
    CSC_NAVIGATEBACK = 0x2              <-- GoBack是2
        } CommandStateChangeConstants;我在.NET Final Release上试了一下,确实可以得到各种command=1/2, enable=ture/false的情况,应该是好的。由于没装Beta2,所以也没试。
    不如升级到Final Release吧,既然是Beta,bug是难免的。:)
      

  3.   

    刚在Beta2上试过,结果正确!
      

  4.   

    以下是检测command和enable的值代码,是否有错误,请指出. 谢谢!
    private void axWebBrowser1_DownloadComplete(object sender, System.EventArgs e)
    {
         label1.Text=this.back.ToString();
         textBox2.Text=this.benable.ToString();
    }private void axWebBrowser1_CommandStateChange(object sender, AxSHDocVw.DWebBrowserEvents2_CommandStateChangeEvent e)
    {
         this.back=e.command;
         this.benable=e.enable;
    }
      

  5.   

    每打开一个连接,WebBrowser会送两个CommandStateChange事件,分别对应与Back和Forward(如果忽略command=-1的情况)。而只会有一个DownloadComplete事件。
    按照你的代码,每次浏览都会有一个CommandStateChange丢失,也许恰好是Back的。:)bool canBack = false, canForward = false;
    private void axWebBrowser1_CommandStateChange(object sender, AxSHDocVw.DWebBrowserEvents2_CommandStateChangeEvent e)
    {
         if (e.command == 1) canForward = e.enable;
         if (e.command == 2) canBack = e.enable;
    }
      

  6.   

    shdocvw.dll在哪引用?我怎么没找到?
      

  7.   

    我仍然无法找出e.command=2这个值,只能找出e.command=1,请提供详细代码如何找出e.command=2和e.enable的值.谢谢!!
      

  8.   

    你在CommandStateChange事件里加上一个MessageBox,每次都把e.command和e.enable打出来,不就得了。