Note that there are some explanatory texts on larger screens.

plurals
  1. POOld drag and drop code no longer works in windows 7
    text
    copied!<p>I have some code that allows me to drag and drop a hyperlink from a webpage onto a windows form, and it seperates the URL and the Title and puts them in two different text boxes.</p> <p>This works on windows XP fine, but on windows 7 it no longer works. I'm not sure where the difference lies.</p> <pre><code>object data = e.Data.GetData("UniformResourceLocator"); </code></pre> <p>data will always be null, but when i use</p> <pre><code> string[] fmts = e.Data.GetFormats(); </code></pre> <p>one of fmts will always be UniformResourceLocator, along with a bunch of other ones that I can never seem to get any data from. If anyone has an resources to point me to or something I would greatly appreciate it, this is really confusing for me.</p> <p>Thanks.</p> <p>UPDATE:added method code that used to work</p> <pre><code> string hyperLinkUrl = null; string hyperLinkText = null; hyperLinkUrl = e.Data.GetData(typeof(string)) as string; // some browser deliver url and text // in UniformResourceLocator (Firebird) string[] tokens = null; if (hyperLinkUrl != null) { tokens = hyperLinkUrl.Split('\n'); } if (tokens != null &amp;&amp; tokens.Length &gt; 1) { hyperLinkUrl = tokens[0]; hyperLinkText = tokens[1]; } // we have to read FILEGROUPDESCRIPTOR to get the text (IE) else { System.IO.Stream ioStream = (System.IO.Stream)e.Data.GetData("FileGroupDescriptor"); byte[] contents = new Byte[512]; try { ioStream.Read(contents, 0, 512); } catch (Exception x) { } ioStream.Close(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); //The magic number 76 is the size of that part of the //FILEGROUPDESCRIPTOR structure before // the filename starts - cribbed //from another usenet post. for (int i = 76; contents[i] != 0; i++) { sb.Append((char)contents[i]); } if (!sb.ToString(sb.Length - 4, 4).ToLower().Equals(".url")) { throw new Exception("filename does not end in '.url'"); } hyperLinkText = sb.ToString(0, sb.Length - 4); } tbLinkTitle.Text = hyperLinkText; tbLinkAddress.Text = hyperLinkUrl; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload