Handled a strange issue, wanted to share: One of my customers wanted to drag-drop an EMF file from her application to Word now the basic problem here is there are incompatibilities between EMFs in windows and .NET and that's why they can not use IDataobject here, details on KB 323530
We tried using different approaches like:
1) Using APIs to get the window below the pointer getting the handle and pasting the emf(which never worked properly, because it was tooinconsistant to be used in a real world enviornment)
2) Converting .NET emf to windows emf putting it to clipboard dropping an empty string to word then doing Selection.Paste (word automation), which was not in sync with customers use of DataObejct
3) So we used the HTML clipboard format(with <img src="emf_file_name">), something like
s += "EndFragment:00000000\r\n<html><body>\r\n<!--StartFragment -->\r\n";
s += "<img src=\"<path>\\<filename>\">";
s += "<!--EndFragment-->\r\n</body>\r\n</html>";
added this to dataobject and dropped it in word, worked perfectly BUT.....
When you drop the image directly (from explorer) in word it displays in its print resolution, when you drop it using HTML the image is displayed in its screen resolution and in this specific case these two are very different resolutions, so the resolution to this came from ....no programming 🙂 pure mathematics..
we finally came up with
============== ===== X ==== =============== = actual print size
============== ===== X ==== =============== = actual screen size
Average monitor resolution(96) Average monitor resolution(96)
came up with the conversion equation...and bang.....!! one of the most importand help came from