Shield Button

Windows Vista introduced us to UAC. One cornerstone for developers was displaying shield next to a button that requires elevation. And it is shame that most application still don’t draw it.

Code is really simple:

var hIcon = NativeMethods.LoadImageW(IntPtr.Zero, NativeMethods.IDI_SHIELD, NativeMethods.IMAGE_ICON, 24, 24, NativeMethods.LR_DEFAULTCOLOR);
if (!hIcon.Equals(System.IntPtr.Zero)) {
    var icon = System.Drawing.Icon.FromHandle(hIcon);
    if (icon != null) {
        this.TextImageRelation = TextImageRelation.ImageBeforeText;
        this.Image = icon.ToBitmap();
    }
}

As you can see, all things are done in first line. Using Interop we request for a system’s shield icon, sized 24x24 pixels in default color. All other lines are there just to be sure that something was loaded and you are not crashing if not (e.g. if you are running XP).

Notice that one could use SystemInformation.SmallIcon to determine “proper” icon size. Unfortunately that will not have nice result for icon sizes that are not 16x16, 24x24 and 32x32. You could always do some fancy smoothing but at such small icon sizes I think it is best to go for something that is of native size.

As example I took liberty to make Button control with UAC shield. Full source is available for download.

MagiWOL 3.20

Illustration

MagiWOL is IPv6 ready.

If you are on network that supports ONLY IPv6, you will really appreciate it since most of Wake-on-LAN programs are unable to work in that scenario.

If you are on dual stack (Windows Vista and newer) and behind your IPv4 home router, this change does not matter much now. Once your home IP pool gets exhausted, you will need it (there is only 4M addresses). Consider this update as future-proofing…

Hyper-V 8

Microsoft Hyper-V Server is great for those who cannot spend much on virtualization infrastructure. It is completely free.

And now it got number 8 and beta designation also. Check Hyper-V Server 8 (beta).

Digi-key

My work brought me to USA for couple of months now. Since I cannot live without solder-smell I had few electronics order here and there. Something from SparkFun, something from Mouser, something from others…

I always pay with my credit card (issued in Croatia) and I had no problem what-so-ever. That is until I tried Digi-Key.

I filled-out the order, payed with credit card and went to sleep. In morning I got:

_Thank you for your order. However, before I am able to proceed, I do need some additional information.

You are shipping to the USA and billing to Croatia. Are you shipping to a freight forwarder? If so, please provide name and website as this can change the tax status of the order. Would you always ship to this address?

Please verify the phone number for the shipping address and for the Croatia address.

Please also provide more information on the application of the parts. What type of application will this product be used in? Example: automotive, medical, telecommunications, etc_

This is annoying. If I say that I want it shipped to USA, why is there questioning of that decision? All other stores could live with me moving to another country. Why can’t Digi-Key?

And this is not the first mail I got from them, they already confirmed my address once. Will I go through same dance every time?

Why do I need to tell what I am using this chips for? Cannot somebody order chips without any particular project in mind other than to have fun?

It might not seem like a huge issue, but I hate this “customer must be wrong approach”. It forces me to babysit my e-mail after sending order and makes everything late by one day at least.

P.S. They did send package, but only after calling my hotel and checking me out. I really appreciate being called liar…

Windows 8

Illustration

Windows 8 download is here. Go get it.

And, while you are at it, get Windows 8 Server beta and a Visual Studio 11 beta.

[2012-03-01: I just finished installation and it cannot either install .NET Framework not it can do Windows Update. Somebody screwed-up something…]

P.S. And I still cannot run my own software without running through hoops since Windows 8 “protects me”.

Illustration

P.P.S. And, since my computer has no SLAC, Hyper-V as single reason for upgrade is there no more… :(