RSS .92| RSS 2.0| ATOM 0.3
  • Home
  • About
  • Eric’s Toolset
  • Free Software
  • Software License
  •  

    .NET Color Struct Equality

    December 16th, 2009

    When is white not white? When one is Color.White and the other is Color.FromArgb(0xff, 0xff, 0xff, 0xff).

    Read the rest of this entry »


    Transparent WinForms Label

    November 28th, 2009

    Easy control transparency isn’t exactly a hallmark of Windows Forms. If you have a form with a background image or a gradient, the stock controls paint with a solid background to give a criminally egregious aesthetic.

    Read the rest of this entry »


    Rounded Rectangluar Regions

    November 19th, 2009

    There are lots of examples that demonstrate how to draw a rectangle with rounded corners using GDI+ in .NET. Converting such a rectangle to a Region so that it can be filled or be used for the geometry of a window can have less than perfect results, though.
    Read the rest of this entry »


    The Best of PDC 2008

    January 17th, 2009

    For those of us poor folk who didn’t make it to PDC this past fall, Microsoft has been taking the show to us in the form of its MSDN Unleashed series. Rob Bagby, developer evangelist, came to Salt Lake City to present and give updates about new and upcoming technologies for developers.

    Read the rest of this entry »


    .NET Cold Startup Performance: More

    June 3rd, 2008

    A few months ago I wrote about an approach to improving .NET cold startup performance. Here’s a little more information that I’ve learned since then.

    Read the rest of this entry »


    Are .NET Properties a Mistake?

    April 24th, 2008

    As I mentioned the other day, I’m reading Jeffrey Richter’s book CLR via C# right now. I was kind of surprised to read this statement by the author: “If I had been involved in the design of the .NET Framework and compilers, I would not have offered properties at all…” (p. 218) Read the rest of this entry »


    .NET Cold Startup Performance: An Example

    March 6th, 2008

    When running a .NET application for the first time after rebooting or hibernating the computer, you might find that it takes a long time to start up. I’ve been trying to address this problem in a few situations recently. In spite of having read several articles on the subject, I wasn’t having much success. Following some of the advice gave no noticeable improvement, and some (like using NGEN) actually slowed down startup. But I had some success recently, so I thought I’d explain how.

    Read the rest of this entry »


    Getting the Host’s Main Window Handle in an Office Add-in

    January 23rd, 2008

    Sometimes you want the window handle of the host application when you’re writing an Office add-in. Excel includes that as a property of the Application object in newer versions of the object model, but Word and PowerPoint don’t. I seem to remember some sample code from Microsoft that suggests using FindWindow to get the handle, but that always seems problematic:

    • You can search by class name (e.g. “OpusApp” for Word), but what if you somehow have multiple Word processes running? Which window do you get?
    • You can search by window text, but it can be really hard to figure out what the window text is.
    • You can set the Caption property on the Application object to some magic text and search for a window with the magic text, but Word throws all kinds of other stuff into the caption so this generally doesn’t work reliably.

    Instead, if you’re using managed code, you can just do this:

    IntPtr hwnd = Process.GetCurrentProcess().MainWindowHandle;

    Underneath this uses EnumWindows and GetWindowThreadProcessId to find the right window.


    Why StringComparison.Ordinal Is Usually the Right Choice

    October 15th, 2007

    A question that arose in response to my previous post (about how string comparisons can produce unexpected results when done in a culture-sensitive way) was Which is right, StringComparison.Ordinal or StringComparison.InvariantCulture? The short answer: StringComparison.Ordinal.

    Read the rest of this entry »


    Unicode Surprises

    October 11th, 2007

    I got a defect from QA today saying that our product was unable to track files in paths containing Unicode characters. I’ll admit that I was skeptical. I had just tried that myself the other day and it worked perfectly. Trying it again today also worked perfectly, but the QA engineer showed me otherwise.

    Read the rest of this entry »