很久以前用VB6做过,不太记得了(我连VB6都忘得差不多了),好象是首先要设置页面的ID,然后在VB6控件中设置HELP ID什么的就可以了,.NET中还没有试过。

解决方案 »

  1.   

    .net中实现类似的功能比在vb6中要简单多了,明天我把代码贴上来!
      

  2.   

    ' Display Help using the provided keyword. 
    Help.ShowHelp(Me, helpfile, keyword.Text)' Display the index for the Help file.
    Help.ShowHelpIndex(Me, helpfile)
      

  3.   

    用JavaScript搞定
    /在页面中按F1寻求帮助时, 执行此功能
    //要求在相应页面有一隐藏元素叫HelpID, 它的值格式为 ModuleName1/ModuleName2_tagName
    window.onhelp = openhelp;
    function openhelp()
    {
    try
    {
    if(document.all("HelpID"))
    {
    //
    var cur_helpid = document.all("HelpID").value;
    var cur_ids = cur_helpid.split("_");
    var cur_modules = cur_ids[0].split("/");
    var cur_tagName = cur_ids[1];
    var cur_temp = "/Help";
    for(var i = 0; i < cur_modules.length; i ++)
    {
    cur_temp += "/" + cur_modules[i];
    }
    cur_temp += ".htm";
    if(cur_tagName != null && cur_tagName != "")
    {
    cur_temp += "#" + cur_tagName;
    }
    //window.showModelessDialog(cur_temp, "", "dialogHeight:600px;dialogWidth:800px;status:no;resizable:yes;help:no;center:no;");
    window.open(cur_temp, "_help", "menubar=no,status=no,toolbar=no,scrollbars=yes");
    }
    else
    {
    //alert("此页面不存在帮助文件");
    }
    }
    catch(e)
    {
    //alert("此页面不存在帮助文件");
    }
    return false;
    }
      

  4.   

    小弟也有这个问题,realmax可否说得详细一点?多谢了!!
      

  5.   

    对,realMax,再说的详细点吧,先谢了啊 
      

  6.   

    代码有点长,希望大家见谅(代码是VB.NET的,没时间转成C#了)!
    代码的作用是通过不同的索引或则是关键字打开CHM文件中指定的页面:Imports System
    Imports System.Drawing
    Imports System.ComponentModel
    Imports System.Windows.FormsPublic Class Form1
        Inherits System.Windows.Forms.Form
        Private helpfile As String = "Help_Test.chm"
        Private WithEvents showIndex As System.Windows.Forms.Button
        Private WithEvents showHelp As System.Windows.Forms.Button
        Private WithEvents label1 As System.Windows.Forms.Label
        Private WithEvents navigatorCombo As System.Windows.Forms.ComboBox
        Private WithEvents showKeyword As System.Windows.Forms.Button
        Private WithEvents keyword As System.Windows.Forms.TextBox
        Private WithEvents label2 As System.Windows.Forms.Label
        Private WithEvents label3 As System.Windows.Forms.Label
        Private WithEvents parameterTextBox As System.Windows.Forms.TextBox    <STAThread()> _
        Shared Sub Main()
            Application.Run(New Form1)
        End Sub 'Main    Public Sub New()
            Me.showIndex = New System.Windows.Forms.Button
            Me.showHelp = New System.Windows.Forms.Button
            Me.navigatorCombo = New System.Windows.Forms.ComboBox
            Me.label1 = New System.Windows.Forms.Label
            Me.showKeyword = New System.Windows.Forms.Button
            Me.keyword = New System.Windows.Forms.TextBox
            Me.label2 = New System.Windows.Forms.Label
            Me.label3 = New System.Windows.Forms.Label
            Me.parameterTextBox = New System.Windows.Forms.TextBox        ' Help Navigator Label
            Me.label1.Location = New System.Drawing.Point(112, 64)
            Me.label1.Size = New System.Drawing.Size(168, 16)
            Me.label1.Text = "Help Navigator:"        ' Keyword Label
            Me.label2.Location = New System.Drawing.Point(120, 184)
            Me.label2.Size = New System.Drawing.Size(100, 16)
            Me.label2.Text = "Keyword:"        ' Parameter Label
            Me.label3.Location = New System.Drawing.Point(112, 120)
            Me.label3.Size = New System.Drawing.Size(168, 16)
            Me.label3.Text = "Parameter:"        ' Show Index Button
            Me.showIndex.Location = New System.Drawing.Point(16, 16)
            Me.showIndex.Size = New System.Drawing.Size(264, 32)
            Me.showIndex.TabIndex = 0
            Me.showIndex.Text = "Show Help Index"        ' Show Help Button
            Me.showHelp.Location = New System.Drawing.Point(16, 80)
            Me.showHelp.Size = New System.Drawing.Size(80, 80)
            Me.showHelp.TabIndex = 1
            Me.showHelp.Text = "Show Help"        ' Show Keyword Button
            Me.showKeyword.Location = New System.Drawing.Point(16, 192)
            Me.showKeyword.Size = New System.Drawing.Size(88, 32)
            Me.showKeyword.TabIndex = 4
            Me.showKeyword.Text = "Show Keyword"        ' Help Navigator Combo
            ' 
            Me.navigatorCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
            Me.navigatorCombo.Location = New System.Drawing.Point(112, 80)
            Me.navigatorCombo.Size = New System.Drawing.Size(168, 21)
            Me.navigatorCombo.TabIndex = 2        ' Keyword TextBox
            Me.keyword.Location = New System.Drawing.Point(120, 200)
            Me.keyword.Size = New System.Drawing.Size(160, 20)
            Me.keyword.TabIndex = 5
            Me.keyword.Text = ""
            ' 
            ' Parameter TextBox
            ' 
            Me.parameterTextBox.Location = New System.Drawing.Point(112, 136)
            Me.parameterTextBox.Size = New System.Drawing.Size(168, 20)
            Me.parameterTextBox.TabIndex = 8
            Me.parameterTextBox.Text = ""        ' Set up how the form should be displayed and add the controls to the form.
            Me.ClientSize = New System.Drawing.Size(292, 266)
            Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.parameterTextBox, _
                                    Me.label3, Me.label2, Me.keyword, Me.showKeyword, _
                                    Me.label1, Me.navigatorCombo, Me.showHelp, Me.showIndex})
            Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
            Me.Text = "Help App"        ' Load the various values of the HelpNavigator enumeration
            ' into the combo box. 
            Dim converter As TypeConverter
            converter = TypeDescriptor.GetConverter(GetType(HelpNavigator))        Dim value As Object
            For Each value In converter.GetStandardValues()
                navigatorCombo.Items.Add(value)
            Next value
        End Sub 'New    Private Sub showIndex_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles showIndex.Click
            ' Display the index for the Help file.
            Help.ShowHelpIndex(Me, helpfile)
        End Sub 'showIndex_Click
        Private Sub showHelp_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles showHelp.Click
            ' Display Help using the Help navigator enumeration
            ' that is selected in the combo box. Some enumeration
            ' values make use of an extra parameter, which can
            ' be passed in through the Parameter text box.
            Dim navigator As HelpNavigator = HelpNavigator.TableOfContents
            If Not (navigatorCombo.SelectedItem Is Nothing) Then
                navigator = CType(navigatorCombo.SelectedItem, HelpNavigator)
            End If
            Help.ShowHelp(Me, helpfile, navigator, parameterTextBox.Text)
        End Sub 'showHelp_Click
        Private Sub showKeyword_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles showKeyword.Click
            ' Display Help using the provided keyword. 
            Help.ShowHelp(Me, helpfile, keyword.Text)
        End Sub 'showKeyword_Click
    End Class 'Form1
      

  7.   

    最好还是.net框架下的Help类,
    调用Help.ShowHelp(this, **.chm,**.htm)
    this 一般是窗体,