Click here to Skip to main content
15,886,362 members
Articles / Desktop Programming / Windows Forms

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

Rate me:
Please Sign up or sign in to vote.
4.67/5 (12 votes)
4 May 2011CPOL5 min read 64K   2.2K   48  
Use HTMLHelp (.chm) to display help topics, context sensitive help and tooltips in C# Winform application
using System;
using System.Security;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.OLE.Interop;


namespace WinHelpLib
{

    /// <summary>
    /// ITStorage control data struct
    /// </summary>
    [ComVisible(false), StructLayout(LayoutKind.Sequential)]
    struct ITS_Control_Data
    {
        /// <summary>
        /// Controldata flag
        /// </summary>
        public UInt32 cdwControlData;
        /// <summary>
        /// Controldata flag
        /// </summary>
        public UInt32 adwControlData;
    }

    enum ECompactionLev
    {
        COMPACT_DATA = 0,
        COMPACT_DATA_AND_PATH
    }

    /// <summary>
    /// .NET interface wrapper for InfoTech interface for ITStorage COM object
    /// </summary>
    [ComImport,
    Guid("88CC31DE-27AB-11D0-9DF9-00A0C922E6EC"),
    InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
    SuppressUnmanagedCodeSecurity]
    interface ITStorage
    {
        [return: MarshalAs(UnmanagedType.Interface)]
        IStorage StgCreateDocfile([In,
                MarshalAs(UnmanagedType.BStr)] string pwcsName,
                int grfMode,
                int reserved);

        [return: MarshalAs(UnmanagedType.Interface)]
        IStorage StgCreateDocfileOnILockBytes(ILockBytes plkbyt,
                                    int grfMode, int reserved);

        int StgIsStorageFile([In,
             MarshalAs(UnmanagedType.BStr)] string pwcsName);
        int StgIsStorageILockBytes(ILockBytes plkbyt);

        [return: MarshalAs(UnmanagedType.Interface)]
        IStorage StgOpenStorage([In,
                    MarshalAs(UnmanagedType.BStr)] string pwcsName,
                    IntPtr pstgPriority,
                    [In, MarshalAs(UnmanagedType.U4)] int grfMode,
                    IntPtr snbExclude,
                    [In, MarshalAs(UnmanagedType.U4)] int reserved);

        [return: MarshalAs(UnmanagedType.Interface)]
        IStorage StgOpenStorageOnILockBytes(ILockBytes plkbyt,
                    IStorage pStgPriority,
                    int grfMode,
                    IntPtr snbExclude,
                    int reserved);

        int StgSetTimes([In, MarshalAs(UnmanagedType.BStr)] string lpszName,
                        Microsoft.VisualStudio.OLE.Interop.FILETIME pctime,
                        Microsoft.VisualStudio.OLE.Interop.FILETIME patime,
                        Microsoft.VisualStudio.OLE.Interop.FILETIME pmtime);
        int SetControlData(ITS_Control_Data pControlData);
        int DefaultControlData(ITS_Control_Data ppControlData);
        int Compact([In, MarshalAs(UnmanagedType.BStr)] string pwcsName,
                         ECompactionLev iLev);
    }


    // Declare ITStorageCoClass as a COM coclass:
    [ComImport, Guid("5d02926a-212e-11d0-9df9-00a0c922e6ec")]
    class ITStorageCoClass   // Cannot have a base class or interface list here.
    {
        // Cannot have any members here 
        // NOTE that the C# compiler will add a default constructor
        // for you (no parameters).
    }

}

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)


Written By
Software Developer (Senior)
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions