Stu Smith: Making It Up As I Go Along
“ My life working for BinaryComponents, coding, design, and other stuff. ”
Pretty much all my development work at BinaryComponents has been done on a nice little Dell that we bought about 18 months ago, originally supplied with XP Pro. Unfortunately, in common with most desktop machines, it's been getting slower and slower as the cruft accumulated. Finally it all got too much for me, and I decided to wipe the whole lot and install Vista instead - and since I can see 2Gb RAM isn't going to be enough for much longer, I decided to go for a 64-bit version.
As you can see, it's all installed nicely, with service pack 1 on too, and in general it's a pleasure to use. There is one exception unfortunately... as some of our users have pointed out on the forums, FeedGhost has a few issues when running on 64-bit Vista. This week, I've been tracking them down. Here's one of them:
Yuck. It's not even as if FeedGhost is coded in some legacy language; it's a pretty standard .NET / Windows Forms application really.
A couple of days' hair-tearing, debugging, tracing, and stepping through the framework source code led me to this in Control.SetBoundsCore (Microsoft code, Microsoft comments):
SafeNativeMethods.SetWindowPos(new HandleRef(window, Handle), NativeMethods.NullHandleRef, x, y, width, height, flags);
// NOTE: SetWindowPos causes a WM_WINDOWPOSCHANGED which is processed
// synchonously so we effectively end up in UpdateBounds immediately following
// SetWindowPos.
//
//UpdateBounds(x, y, width, height);
I now had enough information to cross-reference with an MSDN forum post:
"A little investigation showed that Windows stops sending WM_SIZE when it reaches some certain nesting level. In other words, it won't send WM_SIZE to your child windows if you try to resize them when you process WM_SIZE in the parent ones. Depending on the USER stuff/updates/serivice packs the maximum nesting level at which it stops propagating WM_SIZE may vary from 15 to 31 and even much higher (effectively unreachable) under latest XP 32bit/sp2.
But it still too little under XP x64 and still some similar ugly things happen to other messages under some builds of Vista.
So it is certainly a Windows bug."
Don't you just love it? I know there have to be nesting limits, but 15? Way too low. (And besides, Windows Forms shouldn't expose that nastiness - the code in SetBoundsCore could have checked that the message was relayed, and if not, updated the bounds 'manually').
[ As Joel calls it, this is a good example of a "Leaky Abstraction" - that article by the way is well worth reading, if you haven't already. ]
If you happen to experience this problem, you have two choices: either reduce the depth of your control hierarchy (the more ideal solution), or else derive "fixed" controls from each of the system ones that you use, as follows:
public class FixedPanel : Panel
{
protected override void SetBoundsCore( int x, int y, int width, int height, BoundsSpecified specified )
{
base.SetBoundsCore( x, y, width, height, specified );
if( specified != BoundsSpecified.None )
{
if( ( specified & BoundsSpecified.X ) == BoundsSpecified.None )
{
x = Left;
}
if( ( specified & BoundsSpecified.Y ) == BoundsSpecified.None )
{
y = Top;
}
if( ( specified & BoundsSpecified.Width ) == BoundsSpecified.None )
{
width = Width;
}
if( ( specified & BoundsSpecified.Height ) == BoundsSpecified.None )
{
height = Height;
}
}
if( x != Left || y != Top || width != Width || height != Height )
{
UpdateBounds( x, y, width, height );
}
}
}
Ugly, but it (mostly) works.
I've managed to trim a few unneeded panels out of the deeper hierarchies in FeedGhost, and assuming testing goes OK, this issue will be fixed in the next release of FeedGhost.
We're currently in the process of re-launching our company website: here's one theme we came up with...
...and we wanted to bring it a little bit more up-to-date with an eye-catching spread of a part of our portfolio.
I've used the 3-D screenshot effect before, notably on the FeedGhost website, and although one image is simple enough in Photoshop, I've never been able to get it looking quite right with more than one.
Today however I decided to bite the bullet and get it sorted properly. To that end, I wrote a little WPF-3D application that lets you import images, move and rotate them, and view them from various angles, and finally render them with a shiny reflection. Here's a few examples:

![]()
Once I've tidied this application up a little I'll put it on our labs page for download.