Archive
HowTo: Tell IE to use compatibility mode without editing your web pages
one reads:
We are using Telerik’s rich text editor (RadEditor), and it seems that RadEditor has specific behaviour regarding insertion of break tags.
To circumvent this issue please try to add host header in ISS 7 (website level):
Name = "X-UA-Compatible"
Value = "IE=EmulateIE10"Or, you can insert Html Meta tag on a PreRender event (of Page that uses RadEditor):
HtmlMeta meta =
new
HtmlMeta();
meta.Attributes.Add(
"http-equiv"
,
"X-UA-Compatible"
);
meta.Attributes.Add(
"content"
,
"IE=EmulateIE10"
);
Page.Header.Controls.Add(meta);
This is a very handy trick, one can open up a website at IIS console and open HTTP Response Headers node and then add the Name / Value pair X-UA-Compatible / IE=EmulateIE10 to force say Internet Explorer 11 to behave like Internet Explorer 10
To confirm it works, press F12 to show developer tools in IE11 and see at the right that it says “IE10” instead of “Edge” at the HTML engine selection dropdown list (compatibility mode).
Fix: How to remove Trovigo.com, SearchProtect, restore Internet Options
Trovigo.com is an unwanted search engine hijacker that renders Internet Options of Windows / Internet Explorer inaccessible. To restore them on an older Windows XP installation, one way that I’ve found to work is to update Internet Explorer to a newer version, aka IE 8 (say via the embedded Windows Update facility or Microsoft Update website – http://update.microsoft.com)
The software is also probably related to a software (at least on the machine I was fixing) called "Search Protect", that is running a service and two other processes that one launches, that tries to stop you from killing it and from changing search engine option in the web browser. To remove that you can use Process Explorer from http://www.sysinternals.com:
-
Right-click the SearchProtect service and select Suspend (do the same for the two other processes it uses) to freeze it (breaks into the process with the debugger).
-
Right click the service node (that has the other two processes shown as children under it in the process tree) and select "Kill process tree".
-
Go to %ProgramFiles% (usually C:\Program Files) using Windows Explorer address bar (or type this in Start/Run… dialog and press OK) and remove the folder "SearchProtect"
-
Use free software like CCleaner (http://www.piriform.com) free edition (it has a tool to edit startup entries) or the really powerful Autoruns one to remove the now broken (since you deleted the software at step #3 references in various Windows settings that try to launch the SearchProtect software (Autoruns shows in yellow startup references to missing files, can right click and delete those entries).
HowTo: Save screenshot of a control hosted on a WinForm
I’m trying to automate grabbing of activity screenshots from ClipFlair Activity Gallery, but most command-line screen capturing tools, like SiteShoter and IECapt fail to get an image from Silverlight content (they get just a background color).
Some other opensource tool that I could tweek was ThumbPage, but that didn’t support command-line and needed to disable Silverlight hardware acceleration in the webpage source (that is not define enableGPUAcceleration Silverlight param or set it to false) to grab the Silverlight content too in the image. This is probably because that tool was written in VB6 and must be using plain GDI instead of GDI+ or other newer graphics API, but I’m not sure if that’s the issue with the h/w acceleration.
So, I started making my own WinForms-based tool in Visual Studio. The following sample code is based on ArsenMkrt’s reply at StackOverflow, but this one allows you to capture a control in your form (my tool has a WebBrowser control in it and want to capture just its display). Note the use of PointToScreen method:
//Project: WebCapture //Filename: ScreenshotUtils.cs //Author: George Birbilis (http://zoomicon.com) //Version: 20130820 using System.Drawing; using System.Windows.Forms; namespace WebCapture { public static class ScreenshotUtils { public static Rectangle Offseted(this Rectangle r, Point p) { r.Offset(p); return r; } public static Bitmap GetScreenshot(this Control c) { return GetScreenshot(new Rectangle(c.PointToScreen(Point.Empty), c.Size)); } public static Bitmap GetScreenshot(Rectangle bounds) { Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height); using (Graphics g = Graphics.FromImage(bitmap)) g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size); return bitmap; } public const string DEFAULT_IMAGESAVEFILEDIALOG_TITLE = "Save image"; public const string DEFAULT_IMAGESAVEFILEDIALOG_FILTER = "PNG Image (*.png)|*.png|JPEG Image (*.jpg)|*.jpg|Bitmap Image (*.bmp)| *.bmp|GIF Image (*.gif)|*.gif"; //*** NOTE: the string above is a single line, split it for posting here ***// public static SaveFileDialog GetImageSaveFileDialog( string title = DEFAULT_IMAGESAVEFILEDIALOG_TITLE, string filter = DEFAULT_IMAGESAVEFILEDIALOG_FILTER) { SaveFileDialog dialog = new SaveFileDialog(); dialog.Title = title; dialog.Filter = filter; return dialog; } public static void ShowSaveFileDialog(this Image image, IWin32Window owner = null) { using (SaveFileDialog dlg = GetImageSaveFileDialog()) if (dlg.ShowDialog(owner) == DialogResult.OK) image.Save(dlg.FileName); } } }
Note the “using” clause above, it makes sure that the local variable g of type Graphics is Disposed immediately after the respective clause exits, instead of leaving any allocated resources for the garbage collector to handle. Plus the compiler makes sure the “g” variable isn’t use at the following code in that method by mistake (which could occur if you disposed it there by hand instead).
Having the Bitmap object you can just call Save on it:
private void btnCapture_Click(object sender, EventArgs e) { webBrowser.GetScreenshot().Save("C://test.jpg", ImageFormat.Jpeg); }
The above assumes the Garbage Collector (aka GC) will grab the bitmap, but maybe it’s better to assign the result of someControl.getScreenshot() to a Bitmap variable, then dispose that variable manually when finished, especially if you’re doing this grabbing often (say you have a list of webpages you want to load and save screenshots of them):
private void btnCapture_Click(object sender, EventArgs e) { Bitmap bitmap = webBrowser.GetScreenshot(); bitmap.ShowSaveFileDialog(); bitmap.Dispose(); //release bitmap resources }
Update:
Now WebCapture tool is ClickOnce-deployed from the web (also has nice autoupdate support thanks to ClickOnce) and you can find its source code at http://ClipFlair.codeplex.com.
Speaking of ClickOnce, I noticed that if at the autoupdate dialog shown when you launch the app from its desktop shortcut (and there’s a new version available) you press “Skip”, it won’t offer you this update anymore when you launch an app (I hope that when an even newer update is there it will prompt you), but you can override that behaviour by going to the installation page for your ClickOnce app (where you installed it from in the first place) and press the “Install” button there.
Fix: remove ‘optimized for Bing and MSN’ from IE titlebar
Seems some Microsoft software (probably Bing bar) version is changing Internet Explorer title bar to write “optimized for Bing and MSN”.
To remove this:
- Use Start/Run or Start/Find and type there regedit then press ENTER to launch the Registry Editor.
- At the tree on the left navigate to HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
- At the right handside of the window right click the value “WindowTitle” and select “Delete” to restore the default “- Windows Internet Explorer” suffix on the IE titlebar
more IE9 RC issues – Tale of two Internet shortcuts
Can you spot any difference at the following two Internet shortcuts on my desktop?
I can’t either. Note that the two files have the same “name”, but different file extension (invisible when using default Windows Explorer folder view settings). The one uses “.url” (classic Internet Explorer webpage shortcut), while the other one, created by Internet Explorer 9 RC when I drag-dropped a page’s icon from the address bar onto my desktop, uses the file extension “.website”. That’s why although they seem to the user to have the same name, they can still co-exist on the same folder (the desktop).
However, there are important differences on how these two Internet shortcuts behave. If you open the .url one with IE9 RC you get the window at the 1st image shown below, whereas if you open the “.website” one, you get the window at the 2nd image shown below. Notice the difference on the address bar? The Back and Forward buttons now have a different color (they get their color from the page icon somehow, maybe calculating the dominant color or something from there) and there’s also the page icon showing up at the start of the address bar (can click on it to go back to this page if you’ve navigated away from it).
Note that when you drag-drop the webpage icon from IE9 RC address bar onto the desktop you also do notice a different behaviour (than you were used to) from IE9, in that it closes that page and opens it up in a new window, with that modified address bar, 2nd image as shown below.
Right-clicking each of those two files (the .url and the .website ones), and selecting “Properties”, you get the displays shown below on the left and right sides respectively. You’ll notice that the “.url” file is called an “Internet Shortcut”, whereas the “.website” one is called a “Pinned Site Shortcut”.
Note that the “.url” file’s “Properties” action takes you directly to a tab other than the “General” one, called “Web Document” (a custom property page) with more info on the URL, a tab that is missing (I’d consider this a bug) from the “.website” file properties dialog. That way you can’t edit the URL from the properties dialog, neither can you set a “Shortcut key” for launching the shortcut using the keyboard.
Right-clicking the “.url” file and selecting “Send to > Notepad” (assuming you have installed “SendTo tools” or similar utility, or created a shortcut to “Notepad.exe” at your SendTo folder), you see the following contents:
[InternetShortcut] URL=http://www.guardian.co.uk/commentisfree/cifamerica/2011/feb/14/useconomy-usemployment IconFile=http://www.guardian.co.uk/favicon.ico IconIndex=1
Right-clicking the “.website” file and selecting “Send to > Notepad” (assuming you have installed Send To tools or created a Notepad shortcut at your SendTo folder), you see the following contents:
[{000214A0-0000-0000-C000-000000000046}] Prop4=31,The revenge of trickle-down economics | Richard Wolff | Comment is free | guardian.co.uk Prop3=19,2 [InternetShortcut] URL=http://www.guardian.co.uk/commentisfree/cifamerica/2011/feb/14/useconomy-usemployment IDList= IconFile=http://www.guardian.co.uk/favicon.ico IconIndex=1 [{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}] Prop5=8,Microsoft.Website.CF19EB85.7C0F63A3 [{A7AF692E-098D-4C08-A225-D433CA835ED0}] Prop5=3,0 Prop2=65,2C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF30000005900000085030000D4010000C6 Prop6=3,1
I find the new IE9 RC behaviour non-intuitive, esp. the action of closing old tab and popping up a new window when you drag-drop the page icon from the address bar onto the desktop. This violates the UI design principle of “least surprise” for the user.
Moreover it refreshes the page when doing that (which can result in loss of data if you were filling-in something online and hadn’t submitted yet – hope it does at least respect webpages that use closing event handler to warn the user they haven’t saved and allow them to cancel the page closing).
You can see more info on Pinned Site Shortcuts at http://msdn.microsoft.com/en-us/ie/dd797411 (as a reader of my previous blog post pointed out).
Bug: “The disk is full” at base.bundle.js of #NewTwitter
Sometime ago I got the above error screen (after clicking on the error notice at the statusbar) on IE8/Vista at the new Twitter UI (aka #NewTwitter). Exactly what does “The disk is full.” error mean to say? Wonder if twimg.com (probably used to host images served by Twitter like avatar images) was itself running out of disk space and this was some error string returned via AJAX or if it’s some silly error message (maybe cause their code thought IE8 supports HTML5 local storage or something).
Maybe they’ve fixed it now, but in general even the classic Twitter UI didn’t seem to always play ok with IE8, e.g. Retweet didn’t always work (would see “Error on page” at the bottom) and you had to click on “x minutes ago” under a given status update to go to a page where you could retweet it…
Bug: Dragging webpage icon from IE8’s address bar onto desktop with CTRL pressed
You may already know that dragging current webpage icon from Internet Explorer 8 address bar onto the desktop creates a URL shortcut to that page on the web. However I just found out that holding down CTRL, this action creates a broken .htm file like the following one instead:
<BASE HREF=”http://msdn.microsoft.com/en-us/magazine/ee336122.aspx”>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http:/