Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » Windows Forms » Downloads
 
Add your own
alternative version

C# WinForms Application Full Integration with HTMLHelp ( .chm ) - Help Topics, Context Sensitive Help, and Tooltips

, 4 May 2011
Use HTMLHelp (.chm) to display help topics, context sensitive help and tooltips in C# Winform application
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using WinHelpLib;


namespace WinHelpTest
{
    public partial class MainForm : Form
    {

        public WinHelpEx.HELP_CTRL_USE GetControlName(Control ctrl, ref string sName)
        {
            if (ctrl == btnHelp)
            {
                sName = "ButtonHelp";
                return WinHelpEx.HELP_CTRL_USE.USE_NO_SUB;
            }

            sName = "";
            return WinHelpEx.HELP_CTRL_USE.USE_SUB;
        }
        public WinHelpEx.HELP_CTRL_USE IsControlUsed(Control ctrl)
        {
            return WinHelpEx.HELP_CTRL_USE.USE_SUB;
        }

        public WinHelpEx.HELP_CTRL_USE IsControlTTUsed(Control ctrl)
        {
            if (ctrl == this)
            {
                return WinHelpEx.HELP_CTRL_USE.USE_SUB;
            }
            return WinHelpEx.HELP_CTRL_USE.USE_SUB;
        }


        Boolean IsCSHelpDlgt(Control ctrl)
        {
            if (ctrl == tvHF || ctrl == cbHC || ctrl == this)
            {
                return false;
            }
            return true;
        }

        public MainForm()
        {
            InitializeComponent();

            try
            {

                Program.s_help.TestITSS(tvHF);

                Program.s_help.AttachForm(null, this, true, IsControlUsed, GetControlName, IsCSHelpDlgt, IsControlTTUsed, GetControlName);

            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }

            object[] arr = new[]
            {
                new { Text = "TableOfContents", Data = HelpNavigator.TableOfContents },
                new { Text = "Topic", Data = HelpNavigator.Topic },
                new { Text = "TopicId", Data = HelpNavigator.TopicId },
                new { Text = "Index", Data = HelpNavigator.Index },
                new { Text = "Find", Data = HelpNavigator.Find },
                new { Text = "AssociateIndex", Data = HelpNavigator.AssociateIndex },
                new { Text = "KeywordIndex", Data = HelpNavigator.KeywordIndex }
            };

            cbHC.DisplayMember = "Text";
            cbHC.ValueMember = "Data";
            cbHC.DataSource = arr;

        }

        private void btnHelp_Click(object sender, EventArgs e)
        {
            Program.s_help.ShowHelp(this,(HelpNavigator)cbHC.SelectedValue, tbKW.Text);
        }

        private void MainForm_HelpRequested(object sender, HelpEventArgs hlpevent)
        {

        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Veselin Tenev
Software Developer (Senior)
United Kingdom United Kingdom
No Biography provided

| Advertise | Privacy | Mobile
Web02 | 2.8.140814.1 | Last Updated 5 May 2011
Article Copyright 2011 by Veselin Tenev
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid