Changing the display font of a WebBrowser control in C #?

I am trying to change the display font of a WebBrowser control.

I tried

doc.execCommand("FontName", false, "Arial");

But it seems to work for the selected text.

I want the exact same effect as setting the font inside IE → Internet Options → General → Appearance → Fonts.

Thanks in advance.

Byoungjo

-------- Update -------------

As Mitchell noted, doing the same job that ExeWB does in C # .Net is the goal.

In addition, modifying the registry is somewhat overloaded for this and may require a simpler solution, if one exists. Otherwise, I just say no to this FR.

+3
source share
4 answers

, execWB, Microsoft.

Update

execWB execCommand, .NET.

, futz IE, .

+2

ExecWB, . , ( # 4.0 ):

    private const int OLECMDID_ZOOM = 63;
    private const int OLECMDEXECOPT_DONTPROMPTUSER = 2;

    private void SetZoom(int zoom)
    {
        dynamic obj = webBrowser1.ActiveXInstance;

        obj.ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, zoom, IntPtr.Zero);
    }
+2

HKEY_CURRENT_USER/Software/Microsoft/Internet Explorer, , IDocHostUIHandler2:: GetOverrideKeyPath -. Windows Forms IDocHostUIHandler, , IDocHostUIHandler2 WebBrowserSite. , , . - http://www.codeproject.com/KB/miscctrl/csEXWB.aspx - css IDocHostUIHandler:: GetHostInfo.

0

, :

web.Document.ExecCommand("SelectAll", false, "null");
web.Document.ExecCommand("FontName", false, "Arial"); // or any desired font
web.Document.ExecCommand("Unselect", false, "null");
0

Source: https://habr.com/ru/post/1731032/


All Articles