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

Context Help Made Easy

, 2 Feb 2007
This article introduces a new way of instrumenting your code that enables help authors associate help topics with the application’s visual contexts at any time - even post-compilation – and to do so using the application’s user interface without the involvement of the developer.
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace ContextHelpMadeEasy
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //add message filter
            MessageFilter oFilter = new MessageFilter();
            System.Windows.Forms.Application.AddMessageFilter((IMessageFilter)oFilter);

            Application.Run(new FTestApplication());
        }
    }

    internal class MessageFilter : IMessageFilter
    {
        bool IMessageFilter.PreFilterMessage(ref Message m)
        {
            switch (m.Msg)
            {
                case 0x100: //MSG.WM_KEYDOWN
                    if ((int)m.WParam == (int)Keys.F1)
                    {
                        // Call the help handler.
                        HelpUtility.ProcessHelpRequest(Control.FromHandle(m.HWnd));
                        return true;
                    }
                    break;
            }
            return false;
        }
    }
}

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

Tom Clement
Team Leader
United States United States
I've been programming in C, C++, Visual Basic and C# for almost 30 years. I've worked at Sierra Systems, ViewStar, Mosaix, Lucent, Avaya, Avinon, Apptero and now Serena in various roles over my career.

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 2 Feb 2007
Article Copyright 2007 by Tom Clement
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid