Genilto Dallo Ответов: 1

Отключить автоматическое определение ссылки/url текстового поля webbrowser


Is there any way to disable webbrowser textarea path to url auto detection?
ex. When I input \\somelan\path\to the webbrowser component automatically insert <a href= in the text. 
Or when input \\somepath with space\ the webbrowser replace with <A href="file://\\somelan">\\somepath</a> with space\


Что я уже пробовал:

Не найти, Как отключить это автозаполнение.

1 Ответов

Рейтинг:
0

Genilto Dallo

Решение найдено в: https://itproblemy.pl/questions/23248740/how-to-disable-url-detection-idmautourldetectmode-in-windows-forms-webbrowser-control

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OLECMDTEXT
{
    public uint cmdtextf;
    public uint cwActual;
    public uint cwBuf;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 100)]
    public char rgwz;
}

[StructLayout(LayoutKind.Sequential)]
public struct OLECMD
{
    public uint cmdID;
    public uint cmdf;
}

// Interop definition for IOleCommandTarget.
[System.Runtime.InteropServices.ComImport, Guid("b722bccb-4e68-101b-a2bc-00aa00404770"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleCommandTarget
{
    void QueryStatus(ref Guid pguidCmdGroup, UInt32 cCmds, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] OLECMD[] prgCmds, ref OLECMDTEXT CmdText);
    void Exec(ref Guid pguidCmdGroup, uint nCmdId, uint nCmdExecOpt, ref object pvaIn, ref object pvaOut);
}


//Disable URL DETECT ON WEBBROWSER
            var CGID_MSHTML = new Guid("de4ba900-59ca-11cf-9592-444553540000");
            var IDM_AUTOURLDETECT_MODE = (uint)2400;
            var commandTarget = (IOleCommandTarget)webBrowser2.Document.DomDocument;
            var arg1 = (object)false;
            var arg2 = new Object();
            commandTarget.Exec(ref CGID_MSHTML, IDM_AUTOURLDETECT_MODE, 0, ref arg1, ref arg2);