Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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\


What I have tried:

Not find how to disable this autocomplete.
Posted
Updated 28-Jan-19 15:41pm

1 solution

Solution found in: 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);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900