示例#1
0
        public static void ShowHelp(Control control, string message)
        {
            HH_POPUP popup = new HH_POPUP(Marshal.StringToCoTaskMemUni(message));

            try
            {
                if (GetCursorPos(out popup.pt))
                {
                    RECT      WindowBounds;
                    HandleRef Parent = new HandleRef(control, control.Handle);

                    if (GetWindowRect(Parent, out WindowBounds))
                    {
                        if (!WindowBounds.Contains(popup.pt))
                        {
#warning TODO: proper alignment if partially off the screen

                            popup.pt.X = WindowBounds.Left + ((WindowBounds.Right - WindowBounds.Left) >> 1);
                            popup.pt.Y = WindowBounds.Top + ((WindowBounds.Bottom - WindowBounds.Top) >> 1);
                        }

                        HtmlHelpW(Parent, IntPtr.Zero, HH_DISPLAY_TEXT_POPUP, ref popup); // file parameter must be null
                    }
                }
            }
            finally
            {
                Marshal.FreeCoTaskMem(popup.pszText);
            }
        }
        public static TWindow Bounds <TWindow>(this TWindow @this, WindowBounds windowBounds)
            where TWindow : Window
        {
            @this.Left   = windowBounds.Left;
            @this.Top    = windowBounds.Top;
            @this.Width  = windowBounds.Width;
            @this.Height = windowBounds.Height;

            return(@this);
        }