Archive

Archive for the ‘Windows XP’ Category

Implementing IEPNGFix as a Reusable Control

January 30, 2009 4 comments

Even with IE 8.0 on the horizon, a great deal of our internal users are still using IE 5.5 and 6.0.  While, for the most part, our current coding techniques are unaffected, we did move to using PNG files quite a while ago and are faced with rendering issues as the target audience for a few of our produces expands.

To solve those issues, I’ve been using TwinHelix’s IE PNG Fix behavior with a great deal of success; however, I dislike keeping track of multiple files and references between projects.  It made more sense to make it a reusable control and include it in our shared architecture library.  When Angus releases a new implementation, then I only need to update the control and push out the updated libraries rather than touching HTML in each project.

Here’s how:

1. Download the latest version of IE PNG Fix from here.

2. Add the IEPngFix.htc, blank.gif, and IEPngFix_tilebg.js (if using 2.0 Alpha 3) into your project.  Mark all three files as Embedded Content.

3. Create a basic CSS file that can be added to pages and call the IEPngFix behavior.  Use the full path to the Web Resource (we’ll add those in the next step).  It’s sensitive to the namespace of your project.

img, div, .pngfix, input {

    behavior: url(‘<%=WebResource(“Resources.IEPngFix.htc”)%>’);

}

3. Modify the Properties/AssemblyInfo.cs file and add the approprate Web References.

[assembly: WebResource(“Resources.IEPngFix.css”, “text/css”,

       PerformSubstitution = true)]

[assembly: WebResource(“Resources.IEPngFix.htc”, “text/x-component”,

       PerformSubstitution = true)]

[assembly: WebResource(“Resources.IEPngFix_blank.gif”, “image/gif”)]

[assembly: WebResource(“Resources.IEPngFix_tilebg.js”, “text/javascript”)]

Notice that the HTC behavior file is an “x-component”.  For a full list of MIME references, check out the w3schools.com.  Also, perform substitution allows us to use dynamic calls of resources—within resources, such as in our CSS file.

4. Create a new class that inherits from CompositeControl.  This control will add the javascript and CSS references into our projects.  Override the OnPreRender method and populate the calling Page’s header with the links to our two files.

protected override void OnPreRender(EventArgs e)

{

       // Base Code: http://www.twinhelix.com/css/iepngfix/

       // Include JavaScript for tiled background support.

       string javascriptInclude =

              Page.ClientScript.GetWebResourceUrl(GetType(),

             “Resources.IEPngFix_tilebg.js”);

           

       var jsLink = new HtmlLink

              {

                     Href = javascriptInclude

              };

       jsLink.Attributes.Add(“type”, “text/javascript”);

       Page.Header.Controls.Add(jsLink);

           

       // Include Css file that calls HTC.

       string cssInclude =

              Page.ClientScript.GetWebResourceUrl(GetType(),

             “Resources.IEPngFix.css”);

           

       var cssLink = new HtmlLink

              {

                     Href = cssInclude

              };

       cssLink.Attributes.Add(“rel”, “stylesheet”);

       cssLink.Attributes.Add(“type”, “text/css”);

       Page.Header.Controls.Add(cssLink);

 

       base.OnPreRender(e);

}

That’s it.  Build and add the new control to your project.  You can then add a new forms page and drop the control into the page.  I prefer, however, to keep a “DefaultPage” and inherit my pages from it—add once, apply to all. 🙂

protected void Page_Load(object sender, EventArgs e)

{

       Page.Controls.Add(new IEPngFix());

}

Here we can see the rendered control. The PNG has a transparent background and without IEPngFix shows up as a white box rather than seeing the black background of the page.  Works like a champ!

IEPngFix in Action

Thanks again to Angus Turnbull for this excellent behavior!

Tags: , , , ,

Changing where RDP Windows Open On The Screen

November 5, 2008 1 comment

Have you ever created a saved RDP session and found that it wants to open on the wrong screen or in a half-scrolling window?  It’s annoying, right?

After a random opening one in NotePad2, I realized the RDP files were simply text files of properties.  Easy enough; however, the values are absolutely painful to read through.

Here’s a snippet of the windowing properties:

screen mode id:i:1
desktopwidth:i:1024
desktopheight:i:768
session bpp:i:16
winposstr:s:0,1,400,92,2500,992

I’m assuming that the properties are in order of

name:type:value

“screen mode id” takes an “i” or integer and has a value of 1 (for windowed mode).
“winposstr” takes an “s” or string and has a value of 0,1,400,92,2500,992

“winposstr” sounds a lot like Window Position String, right?

After a bit of Googling, I found KB886187 which discusses each of the attributes; however, forwards you on to another article on MSDN regarding the WINDOWPOS (for winposstr).

Roughly, winposstr follows the following order:

0,[maximized = 0, windows = 1], [left], [top], [window width aka right], [window height aka bottom]

So, I prefer an 1152×864 window (as it fits nicely on my side 1280×1024 monitor), I’d set the desktopwidth and desktopheight to:

desktopwidth:i:1152
desktopheight:i:864

Now, my “main screen” is 1920×1200, so to get things on the right-side screen (which is 1280×1024), I need to move on the left PAST 1920.

winposstr:s:0,1,1970,10,3138,910

  • 1970 is 50 (px) from the left side of my second monitor (1920 + 50)
  • 50 (px) from the top of the screen
  • 3138 (px) is 1970 (starting position) + 1152 (width of the window) + 16 for the window padding (thanks Randy!)
  • 960 (px) is 50 (starting position) + 864 (height of the window) + 46 for horizontal padding and the title bar

Now my RDP window always opens on my second monitor—just about in the center and looks good. 🙂

AnkhSVN 2.0 Released – How’s it look?

When I first started using Subversion full time for all of my personal projects, I stuck with the VisualSVN server and AnkhSVN as a Visual Studio client.  Both were free, easy to install, and easy to use.

However, after a few weeks, the AnkhSVN client could almost be called “annoying.”  It trampled over the existing SCC plugins for SourceSafe (for work) and made a mess out of several of my project uploads.  I ended up going back to using TortioiseSVN and doing everything through Explorer.

When AnkhSVN 2.0 was released, I figured I’d give it another shot.

The site claims quite a bit—including several unique additions:

  • Pending changes window; subversion status and commands available in one place
  • Full support for Visual Studio 2005 and 2008; AnkhSVN is now a SCC package instead of just an addin
  • Better log viewer
  • Merge support
  • Property editor
  • AnkhSVN now supports most project types previously unsupported via the SCC api
  • All solution explorer actions (rename, copy&paste, drag&drop) keep subversion history now
  • Enhanced build process and setup
  • Automatic check for updates
  • And last but certainly not least end user documentation

All of those look great—especially the SCC package and changes window.  But how does it compare once installed?

After installation and starting up VS2008, everything looks normal.

Brief Look

Pending Changes Window

The new pending changes window is FANTASTIC—much improved over the old 1.x versions.  I did run into a snafu when trying to resize the window where the scrollbars didn’t update on the screen; however, I’m not sure if it’s a VSS or AnkhSVN issue.

SCC Package

Under Options > Source Control, AnkhSVN shows up just like it should.

What does boggle me is that all of the Subversion commands and menus are available no matter what—even when the VSS SCC is enabled.  It still has the stink of VSS and SVN trying to step on one another (“pick me! control your project with me! no, I’m better! pick me!”).

Log/History Viewer

I really like the new history viewer.  It’s clean and easy to read; however, if you change the options at the top—there doesn’t appear to be a way to “change it back” and see the history again, close the view and review.

Annoyances

  • Opening a project from Subversion (File > Subversion > Open from Subversion) will open a project just fine, copy it down, but never opens it.  You have to go back and open the solution after it’s created the local structure.  Not huge, but annoying.
  • When viewing history; you cannot view the history of a single file (that I’ve found) in the Repository Explorer. 

I’m still planning to give it a whirl for the next couple of weeks and see what happens.  Hopefully over a couple weeks I’ll have more time to code—it’s been a busy July so far!

FIX: Printing ANYTHING Locks Up Windows Server 2003

June 12, 2008 Comments off

A few days ago, I installed Visual Studio 2008 SP1 Beta and all the goodies that came along with that.  Since then, printing just didn’t work.  If I tried to print, it’d hang up the application for a few minutes (felt like hours) until it’d error out that the printer was not operational.  I could print DIRECTLY from the printer (the test page).  Meh.

Trust me, while trying to prototype a reporting application and print examples there is no happiness when you can’t print.

After several hours of hunting, testing drivers, trying fixes, etc… I finally came across a TOTALLY unrelated MS KB article, #948046.

The article is for Windows Server 2003 with SP2 and XP with SP2–-both x64 and x86 editions.  It focuses on Microsoft Word and not being able to print if the EU Font pack is installed.  The scenario of “Word document is not printed as expected” is pretty vague.

Now, I’ve been using the same HP printer drivers (an 8150 DN and 5550 DTN Color) for ages without any problems, so I can’t fathom that caused the problem, but who knows.  The problem started after installing VS2008 SP1 Beta (I haven’t combed the install logs to see if it reinstalled Unidrv.dll).

Anyway, the fix to this problem, so far (after testing in several applications including Adobe Acrobat, Word, Excel, Visual Studio, and SQL Management Studio), is to download the hotfix in the #948046 article

Install, reboot, and things work perfect.

Adding Multiple System Monitors ala Perfmon

May 22, 2008 Comments off

I use Perfmon a LOT. 

The logging and diagnostic software provided to us is, well, it’s just not that great.  Very slow to use and get around and every time I want a specific counter, I have to go ask for it because it’s someone’s “job” to add those. Ugh.  That’s no way to live.

Until now, I typically have a Perfmon console for each of my major application and SQL servers.  Why?  Because I was never smart enough to figure out how to add additional System Monitor controls into a single performance console.

Well, now I figured it out!

  • File > Add/Remove Snap-in
  • Click Add…
  • Select the ActiveX Control

ActiveX Control

  • A Wizard will start; scroll down and select System Monitor Control

System Monitor ActiveX Control

  • Give your new counter a name!
  • Repeat this until you’ve added your servers.  From there, configure each System Monitor control as needed.

Perfmon with all the servers!

From here, you can either add counters manually or use this brilliant PowerShell script.

FireFox 3.0 Release Candidate 1 Hits the Wire

May 16, 2008 Comments off

I’ve moved from the last beta up to release candidate 1 of FireFox 3 and am quite impressed.  You can read all about the latest version here.  FireFox opens up just as quick (if not quicker) on first run than IE 7 (on Vista). 

NoScript, the latest del.icio.us, IETab, and Adblock Plus all work like a champ. 

I also like the very compact theme that they’ve packaged with RC1–-Strata.

The coolest “tip” that I’ve found is the “Undo Close Tab”—did FireFox 2 have this?  I need to look sometime.  In the tab bar (when tabs are open or if you have it visible all the time), the “Undo Close Tab” reopens and rebrowses to wherever the last … well, closed tab was… brilliant for those times you accidently close the wrong tab!

I’ve browsed around a few dozen sights, dinked with some of the AJAX idea sides, and so far so good regarding rendering.  I’m pleased with this release so far. 🙂

TIP : Extracting Files from an MSI File

May 13, 2008 Comments off

Ever had an MSI file that you needed a library or something out of, but didn’t want to install it?  Amazingly enough, you CAN get to those files.

The Windows Installer (msiexec.exe) can be ran at the command line to extract files directly using an administrative install.

How?

msiexec /a “YourMSIPackage.msi” /qb TARGETDIR=”DRIVE:\YourTargetPath”

Switches used:

/a – Administrative installation
/qb – Basic UI (simple GUI progress bar)

This is a lot easier than hacking it using WinRAR. 🙂

Using the CLR Profiler with VS2008 Web Projects

Download CLR Profiler for .NET 2.0 Framework.

The CLR profiler is great; it’s sweet to be able to see where memory is allocated and how well objects are disposed of (and whether or not I missed something that GC just isn’t catching). 

The form is pretty easy to use, but there’s a bit of a trick for VS 2008 web application profiling when using the built-in Web Development Server.

NOTE:  This isn’t anything like the ANTS Profiler (which I wish I had a license for, but don’t).  ANTS will tell you where code slowdowns are and more, this simply returns back histographs of object usage, memory, and the stack/heap.  Still very useful none the less.

Here’s how to get started:

1. Download the CLR profiler (see the link at the beginning of this article or click here).

2. Extract the profiler into a directory (it defaults to C:\CLRProfiler); it will extract two directory structures (binaries, source) and a readme document.

3. To start using the application immediately, browse into the Binaries directory and execute the CLRProfiler. 

Use the x86 version. I haven’t been able to get the x64 version to work correctly (even though I’m on a x64 machine) when profiling .NET web applications ala the built-in web development server.

4. Under File > Set Parameters, modify the “Command Line” to reflect the parameters required to start the built-in web development server.  After the parameters have been set, click OK.

Usually, you have a Port parameter and a Path parameter.  Here’s an example:

/port:1234 /path:“J:\Projects\Work\Current\ERC\web\”

5. Click ‘Start Application’.  A browse window will open.  Visual Studio 2008’s web development server is located in the Common Files directory.

%CommonProgramFiles%
    \Microsoft Shared\DevServer\9.0
or
%CommonProgramFiles(x86)
    \Microsoft Shared\DevServer\9.0

6. After selecting the WebDev.WebServer.Exe application file, your server will kick off with the parameters you set.

Now you’re ready to open up a web browser, begin browsing around, and evaluate your application.  When finished, click the ‘Kill Application’ button on the Profiler or simply close the WebServer application.

Search Commands for Office 2007 – GREAT!

May 5, 2008 Comments off

I’ve been using Office 2007 for, well, almost forever.  Compared to the prior versions of Office, it’s better than expected—and quite a dynamic change.  By that, I mean the ribbon toolbar. 

I understand Microsoft’s UI “goodness” and some of the ribbon logic—especially on smaller applications, but the ribbon is still painful to use in huge rambling applications like Microsoft Word and Excel.  I still, after all this time, spend time going, “where the heck is {command}?”

Most of the time, I fall back to using old Office commands that, thankfully, still work.  Other times, it’s an adventure!

That adventurous spirit, however, isn’t shared by every user of Office 2007.  The learning curve of the ribbon and other Office 2007 features has been the leading reason why the latest application suite is still frowned upon in our organization.  Face it—the UI for Word looked the same from about Word 6.0 to 2003.  In one version, that’s a lot of users to reeducate.

To ease those users along and empower the “power” users of Office products, the Office Labs team has released a sweet plugin for Microsoft Office 2007–-Search Commands.  Search Commands is exactly what it says, rather than wading through the half-dozen menus, you enter what you want to do in the search box and the ribbon automagically builds for you.

I’ve been using it for a week or so now, since it came out on 23 April, and love it.  Once you get the Search Commands hot keys down (Alt-Y, E and Alt-Y, 1–9) you can wiz through commands.

Add-ons in FireFox 3.0b5

April 18, 2008 4 comments

I decided to toss FireFox 3 on my workstation to see what broke—and unfortunately, almost everything broke.

I use quite a few add-ons; however, the most useful of my add-ons are all toast. 😦

  • del.icio.us Bookmarks
  • Fasterfox
  • Firebug
  • FireShot
  • TinyUrl Creator

There are a few that seem to survive; however, without FireBug and del.icio.us, I just can’t survive.

That aside, there is one very cool 3.0b5 add-on—IETab.  The add-on uses filters and/or the context menus to open up Internet Explorer tabs within FireFox.  Now, when browsing SharePoint Portal or other MSIE-only sites, I never have to leave FireFox.  It’s FANTASTIC.

I hope that, by the time 3.0 is released out of beta and into production, that a few more of the add-on developers have spent the time and upgraded their tools.  There are so many quality add-ons available (the biggest advantage, I think, to IE) that I had to see those fall behind.