Thursday 15 December 2011

How to open office files inside current window

I had a bug today when a program i was working on didn't work, after fixing the file associations, it worked for windows xp, but one of my clients need it to work for windows 7, however in windows 7 there is no real file association menu.
This fix will help you mostly if you are trying to open office files in the same browser window, and:
a) it opens in new office document.
b) it prompt is not displayed(it might be displayed after a few alt+tab)

This will fix it, there will be no prompt of "what do you want to do with", or "do you want to save or open this file", nor will it attempt to open it in a word window, instead it will open in the browser / WebBrowser window.

The fix is simple, make a text file, copy the next content, rename to something.reg, and run. you can incorporate it into the installer of you program to make sure the clients run it.
content:


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.Document.8]
"BrowserFlags"=dword:80000024

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.RTF.8]
"BrowserFlags"=dword:80000024

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.Document.12]
"BrowserFlags"=dword:80000024

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.DocumentMacroEnabled.12]
"BrowserFlags"=dword:80000024

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.Sheet.8]
"BrowserFlags"=dword:80000A00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.Sheet.12]
"BrowserFlags"=dword:80000A00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.SheetMacroEnabled.12]
"BrowserFlags"=dword:80000A00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.SheetBinaryMacroEnabled.12]
"BrowserFlags"=dword:80000A00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.Show.8]
"BrowserFlags"=dword:800000A0

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.Show.12]
"BrowserFlags"=dword:800000A0

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.ShowMacroEnabled.12]
"BrowserFlags"=dword:800000A0

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.SlideShow.8]
"BrowserFlags"=dword:800000A0

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.SlideShow.12]
"BrowserFlags"=dword:800000A0

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.SlideShowMacroEnabled.12]
"BrowserFlags"=dword:800000A0


[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\AttachmentExecute\{0002DF01-0000-0000-C000-000000000046}]
"Word.Document.8" =dword:0
"Word.RTF.8" =dword:0
"Word.DocumentMacroEnabled.12"=dword:0
"Word.Document.12"=dword:0
"Word.DocumentMacroEnabled.12"=dword:0
"Excel.Sheet.8"=dword:0
"Excel.Sheet.12"=dword:0
"Excel.SheetMacroEnabled.12"=dword:0
"Excel.SheetBinaryMacroEnabled.12"=dword:0
"PowerPoint.Show.8"=dword:0
"PowerPoint.Show.12"=dword:0
"PowerPoint.ShowMacroEnabled.12"=dword:0
"PowerPoint.SlideShow.8"=dword:0
"PowerPoint.SlideShow.12"=dword:0
"PowerPoint.SlideShowMacroEnabled.12"=dword:0




Of course you can expand this for other files types, just add the names they are defined under in the registry.
If you are wondering, the first half ( up to [HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\AttachmentExecute\{0002DF01-0000-0000-C000-000000000046}]) is about the new window, the other is fixing the prompt.

The following KB resources were used:
http://support.microsoft.com/kb/927009
http://www.winhelponline.com/blog/reset-the-always-ask-before-opening-this-type-of-file-setting/

Sunday 22 May 2011

Quick post: png in IE7

After i lost the last hour and a half trying to figure out why my site was crawling to a halt and using 100% of a CPU(actually 25% as i'm using a quad core), i figured out the problem.

NEVER. EVER. use a background repeat with a .png image, it seems that using the .png repeat made the .png engine in IE7 render each repeated item individually, making a large transparent background a living hell for the CPU.

the best method to avoid it is not using a smaller image with repeat, and resizing the image to full size, or just use .gif, as it provide transparency, and also works on the old(and bad) IE6.

p.s.
i hate you Microsoft.

Tuesday 22 February 2011

Why is my span tag acting all freakishly?

When you try to design component, you will sometimes need to use the design tag as inline, and sometimes as block, for that purpose there are two tags, the span and the div.

The <span> is used for inline elements, elements you want to use while inline, meaning they do not break new line after.
The <div> is used for block elements, usually used for dividing the page into seperate parts, such as header, main zone, footer etc. as such, it will start a new line after it is completed.
There are other differences, such as inline not receiving height properties.

Of course both can be turned into the other type of display, simply by using the css property "display" to inline or block, or even better, the display type of inline-block, letting your inline items have a height and enjoy the best of both world(and enjoying the havoc of trying to fix the design for IE, as it tends to display it differently for each version).
For example: <div style="display:inline;">.

However, you should note, span is defaulted for inline, as such, it is supposed to contain some content, so if you use it for design(such as using it for a background, with no text inside) it will act weird, the best way to fix it is by adding some content, and the best content? a space that will not be ignored, achieved by the the " &nbsp; " key-word(without the quotation).
Oh, and do take note, if your span is across several lines(not starting and ending in the same line), the line break may cause some chaos, so it is best to keep it in one line, or commenting out the new line(simply start a comment at the end of the line, and end it at the beginning of the first element in the next line).

Sunday 20 February 2011

fixing asp:menu for google chrome asp.net

As some of you using asp.net might notice, Google Chrome has a quirk, it likes simplifying the html code. it isn't very noticeable, most of you will never notice, but when you use the control, the css just doesn't seem to work right for Chrome, the fix for this is to add the following code to your base.master code, or if you dont have a master, to the page's code.

protected override void AddedControl(Control control, int index)
{
if (Request.ServerVariables["http_user_agent"]
.IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1)
{
this.Page.ClientTarget = "uplevel";
}
base.AddedControl(control, index);
}

In case you are wondering why i use the safari as the user agent, that is because Safari and Chrome use the same rendering engine, the WebKit, thus making this fix good for both browsers.
In case you are using Safari and annoyed about only talking about Chrome, don't be insulted that i only talk about Google's Chrome, after all, chrome is 5 times more poplar (Chrome's market share is at around 13% of all browsers usage, while Safari is only at around 2%)