Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
htmlhelp (hhctrl)
 
.
Summary
Open HTML Help

C# Signature:

[DllImport("hhctrl.ocx", SetLastError=true, EntryPoint = "HtmlHelpW", CharSet = CharSet.Unicode)]
static extern IntPtr HtmlHelp(
        IntPtr hWndCaller,
        [MarshalAs(UnmanagedType.LPWStr)]
        string helpFile,
        HTMLHelpCommand command,
        int data );

User-Defined Types:

    [Flags()]
    public enum HTMLHelpCommand : uint
    {
        HH_DISPLAY_TOPIC = 0,
        HH_DISPLAY_TOC = 1,
        HH_DISPLAY_INDEX = 2,
        HH_DISPLAY_SEARCH = 3,
        HH_DISPLAY_TEXT_POPUP = 0x000E,
        HH_HELP_CONTEXT = 0x000F,
        HH_CLOSE_ALL = 0x0012
    }

VB Signature:

<DllImport("hhctrl.ocx", SetLastError:=True, EntryPoint:="HtmlHelpW", CharSet:=CharSet.Unicode)> _
Function HTMLHelp( _
     ByVal hWndCaller As IntPtr, ByVal pszFile As String, _
     ByVal uCommand As Integer, ByVal dwData As Integer) As Integer
End Function

User-Defined Types:

Public Enum HTMLHelpCommand
     HH_DISPLAY_TOPIC = 0
     HH_DISPLAY_TOC = 1
     HH_DISPLAY_INDEX = 2
     HH_DISPLAY_SEARCH = 3
     HH_HELP_CONTEXT = &HF
     HH_CLOSE_ALL = &H12
End Enum

Notes:

None.

Tips & Tricks:

Article "How to use the unmanaged HTML Help API from a managed Visual C# application" on support.microsoft.com

Sample Code:

VB

HTMLHelp(Nothing, filePath, HTMLHelpCommand.HH_HELP_CONTEXT, contextID)

or

HTMLHelp(Nothing, filePath, HTMLHelpCommand.HH_DISPLAY_TOC, 0)

C#

HtmlHelp(IntPtr.Zero, filePath, HTMLHelpCommand.HH_HELP_CONTEXT, contextID)

or

HtmlHelp(IntPtr.Zero, filePath, HTMLHelpCommand.HH_DISPLAY_TOC, 0)

Alternative Managed API:

System.Windows.Forms.Help.ShowHelp()

Documentation
Summary
Open Context Popup Help

C# Signature:

[DllImport("hhctrl.ocx", SetLastError = true, EntryPoint = "HtmlHelpW", CharSet = CharSet.Unicode)]
static extern int HtmlHelp(
        IntPtr hWndCaller,
        [MarshalAs(UnmanagedType.LPWStr)]
        string pszFile,
        HTMLHelpCommand uCommand,
        [MarshalAs(UnmanagedType.LPStruct)]
        HH_POPUP dwData);

User-Defined Types:

    [StructLayout(LayoutKind.Sequential), CLSCompliant(false)]
    struct COLORREF
    {
        uint _ColorRef;
        public COLORREF(Color aValue)
        {
            int lRGB = aValue.ToArgb();
            int n0 = (lRGB & 0xff) << 16;
            lRGB = lRGB & 0xffff00;
            lRGB = (lRGB | (lRGB >> 16 & 0xff));
            lRGB = (lRGB & 0xffff);
            lRGB = (lRGB | n0);
            _ColorRef = (uint)lRGB;
        }
        public COLORREF(int lRGB)
        {
            _ColorRef = (uint)lRGB;
        }
        public Color ToColor()
        {
            int r = (int)_ColorRef & 0xff;
            int g = ((int)_ColorRef >> 8) & 0xff;
            int b = ((int)_ColorRef >> 16) & 0xff;
            return Color.FromArgb(r, g, b);
        }
        public static COLORREF FromColor(System.Drawing.Color aColor)
        {
            return new COLORREF(aColor);
        }
        public static System.Drawing.Color ToColor(COLORREF aColorRef)
        {
            return aColorRef.ToColor();
        }
    }
    [StructLayout(LayoutKind.Sequential)]
    class POINT
    {
        public int x;
        public int y;
        public POINT()
        {
        }
        public POINT(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
    }
    [StructLayout(LayoutKind.Sequential)]
    struct RECT
    {
        public int left;
        public int top;
        public int right;
        public int bottom;
        public RECT(int left, int top, int right, int bottom)
        {
            this.left = left;
            this.top = top;
            this.right = right;
            this.bottom = bottom;
        }
        public RECT(Rectangle r)
        {
            this.left = r.Left;
            this.top = r.Top;
            this.right = r.Right;
            this.bottom = r.Bottom;
        }
        public static RECT FromXYWH(int x, int y, int width, int height)
        {
            return new RECT(x, y, x + width, y + height);
        }
        public Size Size
        {
            get
            {
                return new Size(this.right - this.left, this.bottom - this.top);
            }
        }
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    class HH_POPUP
    {
        internal int cbStruct = Marshal.SizeOf(typeof(HH_POPUP));
        internal IntPtr hinst = IntPtr.Zero;
        internal int idString;
        [MarshalAs(UnmanagedType.LPWStr)]
        internal string pszText;
        internal POINT pt;
        internal COLORREF clrForeground = new COLORREF(-1);
        internal COLORREF clrBackground = new COLORREF(-1);
        internal RECT rcMargins = RECT.FromXYWH(-1, -1, -1, -1);
        [MarshalAs(UnmanagedType.LPWStr)]
        internal string pszFont;
    }

Notes:

None.

Tips & Tricks:

Article "How to use the unmanaged HTML Help API from a managed Visual C# application" on support.microsoft.com

Sample Code:

C#

    Color back_сolor_for_popup_window = Color.FromArgb(255, 255, 192); // yellow background, as in windows
    Point current_cursor_location = Control.MousePosition;

    HH_POPUP param = new HH_POPUP();
    param.pszText = "Without specifying the font instead of text you may obtain the abracadabra";
    param.idString = 0;
    param.pt = new POINT(current_cursor_location.X, current_cursor_location.Y);
    param.clrBackground = COLORREF.FromColor(back_сolor_for_popup_window);
    param.pszFont = "Tahoma,8";
    HtmlHelp(IntPtr.Zero, null, HTMLHelpCommand.HH_DISPLAY_TEXT_POPUP, param);

Alternative Managed API:

System.Windows.Forms.Help.ShowPopup()

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions