C# System.Windows.Forms.WebBrowser控件是否支持DPI?

C# System.Windows.Forms.WebBrowser控件是否支持DPI?,c#,winforms,webbrowser-control,C#,Winforms,Webbrowser Control,如何使System.Windows.Forms.WebBrowser控件使用de DPI_AWARE标志来显示支持DPI的文档?如果有人能发布代码示例,将不胜感激 编辑1:添加更多详细信息 问题在于,px单元被视为普通像素单元(而不是像web一样),因此在150%dpi配置下的大小差别很大,在更高的dpi设置下甚至更大。WebBrowser。版本是11.x class myWebBrowser: System.Windows.Forms.WebBrowser, IDocHostUIHandler

如何使System.Windows.Forms.WebBrowser控件使用de DPI_AWARE标志来显示支持DPI的文档?如果有人能发布代码示例,将不胜感激

编辑1:添加更多详细信息

问题在于,px单元被视为普通像素单元(而不是像web一样),因此在150%dpi配置下的大小差别很大,在更高的dpi设置下甚至更大。WebBrowser。版本是11.x

class myWebBrowser: System.Windows.Forms.WebBrowser, IDocHostUIHandler
{
    private const uint E_NOTIMPL = 0x80004001;
    private const uint S_OK = 0;
    private const uint S_FALSE = 1;
    private HostUIFlags flags = HostUIFlags.DPI_AWARE;

    public myWebBrowser()
    {
        this.DocumentCompleted += OnLoadCompleted;
    }

    private void OnLoadCompleted(object sender, WebBrowserDocumentCompletedEventArgs args)
    {
        ICustomDoc doc = this.Document.DomDocument as ICustomDoc;
        if (doc != null)
        {
            \\code reaches this point
            doc.SetUIHandler(this);
        }
    }

    uint GetHostInfo(ref DOCHOSTUIINFO info)
    {
        info.dwFlags = (int)flags;
        info.dwDoubleClick = 0;
        return S_OK;
    }

    \\other IDocHostUIHandler methods...

}
此处定义了接口:

[ComImport, Guid("3050F3F0-98B5-11CF-BB82-00AA00BDCE0B"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ICustomDoc
{
    [PreserveSig]
    int SetUIHandler(IDocHostUIHandler pUIHandler);
}

[ComImport, Guid("BD3F23C0-D43E-11CF-893B-00AA00BDCE1A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IDocHostUIHandler
{
    [PreserveSig]
    uint ShowContextMenu(int dwID, POINT pt, [MarshalAs(UnmanagedType.Interface)] object pcmdtReserved, [MarshalAs(UnmanagedType.Interface)] object pdispReserved);

    [PreserveSig]
    uint GetHostInfo(ref DOCHOSTUIINFO info);

    [PreserveSig]
    uint ShowUI(int dwID, [MarshalAs(UnmanagedType.Interface)] object activeObject, [MarshalAs(UnmanagedType.Interface)] object commandTarget, [MarshalAs(UnmanagedType.Interface)] object frame, [MarshalAs(UnmanagedType.Interface)] object doc);

   \\etc.
}

[StructLayout(LayoutKind.Sequential)]
internal struct DOCHOSTUIINFO
{
    public int cbSize;
    public int dwFlags;
    public int dwDoubleClick;
    public IntPtr dwReserved1;
    public IntPtr dwReserved2;
}

你试过什么?如果您能发布一个代码示例,我们将不胜感激。对于缺少信息,我们深表歉意。我添加了一个例子,你还需要这个吗?我切换到了CefSharp(铬的C#包装)