public static void ShowPopup2(Control parent, string caption, Point location, Font font = null, Color?backColor = null, Color?foreColor = null)
        {
            font      = font ?? SystemFonts.CaptionFont;
            backColor = backColor ?? Color.FromKnownColor(KnownColor.Window);
            foreColor = foreColor ?? Color.FromKnownColor(KnownColor.WindowText);

            var popup = new HH_POPUP();

            popup.clrBackground = new COLORREF(backColor.Value);
            popup.clrForeground = new COLORREF(foreColor.Value);
            popup.pt            = new POINT(location);
            var pszText = Marshal.StringToCoTaskMemAuto(caption);

            popup.pszText = pszText;
            var pszFont = Marshal.StringToCoTaskMemAuto(
                $"{font.Name}, {font.Size}, , " +
                $"{(font.Bold ? "BOLD" : "")}" +
                $"{(font.Italic ? "ITALIC" : "")}" +
                $"{(font.Underline ? "UNDERLINE" : "")}");

            popup.pszFont = pszFont;
            try
            {
                HtmlHelp(parent.Handle, null, HTMLHelpCommand.HH_DISPLAY_TEXT_POPUP, popup);
            }
            finally
            {
                Marshal.FreeCoTaskMem(pszText);
                Marshal.FreeCoTaskMem(pszFont);
            }
        }
예제 #2
0
 public static extern int HtmlHelp(IntPtr hwndCaller, string pszFile, int uCommand, HH_POPUP dwData);
 static extern int HtmlHelp(IntPtr hWndCaller,
                            [MarshalAs(UnmanagedType.LPWStr)] string pszFile,
                            HTMLHelpCommand uCommand,
                            [MarshalAs(UnmanagedType.LPStruct)] HH_POPUP dwData);