Getting a Handle on it all …

Window Handles that is.

WPF Window Handles.

It’s not hard to get the HWND for a WPF Window. There’s a class that makes it easy to get access to the Win32 based HWND that hosts a WPF Window, called WindowInteropHelper.

I saw this post by Brandon and it made me think, Extension Methods to the rescue!

His solution, although neat, means that there’s an extra object that needs to be created just so that a properties value could be delay loaded. Window handles generally should be obtained and discarded anyway (as they can change), so I thought I’d go with this method to add the Handle property to every WPF Window, without needing to add either a custom class and derive everything from that, or manually add it to every class.

public static class WindowExtension
{
    public static IntPtr GetHandle(this Window w)
    {
        return new WindowInteropHelper(w).Handle;
    }
}

To use:

this.GetHandle()

Done. I don’t mind it being a method in this case as it’s not necessarily a fast operation, and it’s read-only.

What technique would you use?

Photography Book Recommendation – Understanding Exposure

imageI just finished reading a great book on exposure (as it relates to photography).  It’s called Understanding Exposure: How to Shoot Great Photographs with a Film or Digital Camera (Updated Edition). It’s gotten great reviews on Amazon and elsewhere. It covers some of the basics of how cameras work (f-stops, apertures, ISO’s), but dives quickly in to topics such as shutter speed, freezing motion, frontlight, the sky brothers, night and low-light photography, aperture and macro photography and more. It’s about 160 pages long and full color. Although it’s not 100% digital-friendly (there are a few techniques that only work on film cameras), it’s a great book with lots of “correct” shots side-by-side with a “creative” shot of the same scene. Bryan Peterson, the author, explains how there’s at least 6 correct exposures with every photograph you might take, but they aren’t all necessarily “creative” shots.

The book is intended for a SLR/DSLR audience, but many of the techniques apply to modern digital cameras as well. It’s about $17 US right now at Amazon.

This is definitely one of the best “how-to” photography books I’ve purchased at this price.

Slow drain (long lasting) Rechargeable Batteries (Finally!)

imageI really like these rechargeable batteries from Sanyo: the eneloop NiMH Pre-Charged Batteries. Why? Mainly because they are slow drain (yet with decent and consistent power output). Most rechargeable batteries drain completely within several months of their charging. So, they don’t work well in remote controls, flashlights, etc.

These Sanyo eneloop batteries however maintain a charge for over a year of storage (maintaining approximately 85% of their charge)! I just bought 16 of them for some game system controllers, and 8 for my digital camera external flash. They’re reasonably priced (they last a long time and can be recharged hundreds of times), get great reviews overall — a great new innovation in rechargeable batteries. Recommended.

Disabling Apple Software Update on Vista

I’ve complained (and so have many others) about the Apple Software Update functionality — especially now that it suggests that I update software I never had installed (Safari)!

On Vista (and XP is probably similar), there’s a scheduled task that runs once a week to look for updates.

To stop that from occurring, click the start/windows logo button, and type "TASK" into the search box.

image

Select Task Scheduler. (You may need to provide an administrator password or just click continue acknowledging that you’re about to make system changes).

Expand the Task Scheduler library node and then click the Apple node.

image

You should see on the right side an entry named, AppleSoftwareUpdate.

image

Click that entry and either right click and select Disable, or click the item and select the Disable option in the Action list on the right side of the Task Scheduler.

image

Although XP’s task scheduler has a very different user interface, the concept is identical, and you should be able to find and disable the AppleSoftwareUpdater in a similar manner.

Here’s hoping that this stops the annoying "Install Safari" now option.

Note that you should occasionally check for updates manually in ITunes if you disable this functionality. It’s available in the Help menu (Check for Updates).

image

QuickTime checks for updates (according to the documentation and settings), only when the application is running (brilliant!).

Or, if you’re not comfortable with completely disabling the auto update feature, you can change the frequency of update checks using the task scheduler. Instead of disabling the task as shown above, decrease it’s frequency. Don’t disable it as suggested above, instead, right click on the AppleSoftwareUpate line, and select properties.

Click the Triggers Tab, then select the first trigger (in my example, it’s labeled Weekly) and click the Edit button:

image

This shows the details of the weekly trigger. In the screen shot above, I’ve changed it from weekly to once a month (on the last day). I’d recommend you leave the advanced settings as is and just modify the frequency to whatever you’d like. Once a month is reasonable — then you’ll only be annoyed by this update once a month rather than once a week.

If you’re paranoid about security, you’ll probably just need to accept the fact that Apple’s update for this is obnoxious and maybe if enough people complain — Apple will realize the error of their ways and provide a way to ignore new Apple Software that you don’t want to install.