Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than hhctrl, prefix the name with the module name and a period.
<DllImport("hhctrl.ocx", SetLastError:=True, EntryPoint:="HtmlHelpW", CharSet:=CharSet.Unicode)> _
<DllImport("hhctrl.ocx", EntryPoint:="HtmlHelp", CharSet:=CharSet.Auto)> _
Function HTMLHelp( _
ByVal hWndCaller As IntPtr, ByVal pszFile As String, _
ByVal uCommand As Integer, ByVal dwData As IntPtr) As Integer
ByVal uCommand As Integer, ByVal dwData As Integer) As Integer
End Function
[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)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
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 IntPtr 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;
internal IntPtr 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#
string text_to_show_popup = "Without specifying the font instead of text obtain the abracadabra";
string font_for_text_to_show_popup = "Tahoma,8,utf-8";
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";
IntPtr ptrText = Marshal.StringToCoTaskMemAuto(text_to_show_popup);
IntPtr ptrFont = Marshal.StringToCoTaskMemAuto(font_for_text_to_show_popup);
param.pszText = ptrText;
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);
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).