Random musings, kitty pictures, computer tips, and political rants
Monday, June 30, 2008
If you ever say prayers, say them now...
I think I have a shot of getting this apartment. I just talked to the manager and he said "we'll talk soon." Fingers crossed...!
Tuesday, June 3, 2008
Profiles in Stupid: Color Codes in ActiveX Controls
We all know Microsoft is annoyingly proprietary in seemingly pointless ways. However, I had no idea of the true extent of their pointless proprietariness until yesterday, when attempting to do something simple turned into a 3-hour Google research project.
It all started while I was working on a project for work. I wanted to see if there was a way to make a Visio Viewer web part, so we could display network diagrams directly on a web page instead of making people open them in Visio to view them. Turns out the solution to that is quite simple and straightforward. So I implemented it, and it looked great except for one thing: the background color in the Visio Viewer was this God-awful aqua that, besides being God-awful in its own right, totally clashed with the nice default Sharepoint blue. So I decided I'd like the Visio Viewer background to be a nice Sharepoint blue as well.
Seeing the "BackColor" property in the code I pasted into the content editor web part, I figured it would be easy to do. Then, though, I looked at the current value of the BackColor property:
Just to make sure my hex code was on the level, I made a quick test html page in notepad and plugged the hex code in. There was my nice blue. So ok, just converting the hex code to decimal obviously isn't what they're doing here. But what is? Well, I learned what it wasn't: base 8, RGBA, something you can edit easily in either Sharepoint Designer or Visual Studio*. After trolling the Interwebs for any sort of clue, I finally stumbled upon this nugget in an MSDN article:
Wow, you have got to be kidding me. But let's try it with my blue:
So my question is this: why, oh why, did Microsoft feel the need to take such a straightforward, universal standard as hex color codes and adulterate it in such a random manner, then leave next to no trace of documentation on said adulteration?! Answer: they're Microsoft. Par for the course. Sheesh.
* I'm sure, if I knew Visual Studio 2005 better than I do (i.e. hardly at all), I could have found a way to do it in there. But after attempting to for awhile, it became clear to me that continuing to head down that path would not be time-efficient.
It all started while I was working on a project for work. I wanted to see if there was a way to make a Visio Viewer web part, so we could display network diagrams directly on a web page instead of making people open them in Visio to view them. Turns out the solution to that is quite simple and straightforward. So I implemented it, and it looked great except for one thing: the background color in the Visio Viewer was this God-awful aqua that, besides being God-awful in its own right, totally clashed with the nice default Sharepoint blue. So I decided I'd like the Visio Viewer background to be a nice Sharepoint blue as well.
Seeing the "BackColor" property in the code I pasted into the content editor web part, I figured it would be easy to do. Then, though, I looked at the current value of the BackColor property:
param value="16777120" name="BackColor"Now I don't know about you, but I'm much more used to seeing six digit hex color codes, so this kind of threw me for a loop. But I'm smart, so I looked at this number and figured, "hey, that must be a regular hex color code that's been converted to decimal!" So I found the hex code of the blue I wanted, which was 6495ED. I converted it to decimal, popped that number into the BackColor property, and my background was now a lovely...terra cotta? What the heck...?
Just to make sure my hex code was on the level, I made a quick test html page in notepad and plugged the hex code in. There was my nice blue. So ok, just converting the hex code to decimal obviously isn't what they're doing here. But what is? Well, I learned what it wasn't: base 8, RGBA, something you can edit easily in either Sharepoint Designer or Visual Studio*. After trolling the Interwebs for any sort of clue, I finally stumbled upon this nugget in an MSDN article:
The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF). The high byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF). If the high byte isn't 0, Visual Basic uses the system colors, as defined in the user's Control Panel settings and by constants listed in the Visual Basic (VB) object library in the Object Browser.Hmmm...okay then. I had to read it a couple times to understand what it meant, but then I started to get it. So I think what they're saying here is to get back to regular hex codes, you convert to hex, then divvy up the hex number into its three pairs, and those three pairs represent red, green, and blue values, like you see when you're messing with colors in Paint. Let's try to reverse engineer the God-awful aqua using this new hypothesis:
- decimal: 16,777,120
- hex : FF FF A0
- decimal RGB values: red 255, green 255, blue 160
Wow, you have got to be kidding me. But let's try it with my blue:
- hex : 64 95 ED
- switcharoo hex: ED 95 64
- switcharoo decimal: 15,570,276
So my question is this: why, oh why, did Microsoft feel the need to take such a straightforward, universal standard as hex color codes and adulterate it in such a random manner, then leave next to no trace of documentation on said adulteration?! Answer: they're Microsoft. Par for the course. Sheesh.
* I'm sure, if I knew Visual Studio 2005 better than I do (i.e. hardly at all), I could have found a way to do it in there. But after attempting to for awhile, it became clear to me that continuing to head down that path would not be time-efficient.
Subscribe to:
Posts (Atom)