A: 

I wouldn't be surprised if that shadow is intimately tied to the window manager itself; it is after all the window manager who decides what window gets to paint which parts of itself and when it can do it. I don't see it as rocket science to paint that shadow if control over all that is gained, which the window manager has.

Johann Gerell
i don't believe that the `tooltips` common control is painting the drop-shadow itself either. But then what feature of Windows is it making use of?
Ian Boyd
+4  A: 

You can't draw outside your window in the manner you describe.

If you right click your desktop then go to properties/appearance/effects and uncheck 'Show shadows under menus' ... you will no longer have the shadow.

Bottom line is that this is a product of the window manager not your program.

How is the `tooltips` common control drawing outside its window? Or what feature of Windows is it asking to make use of?
Ian Boyd
@Ian Boyd - I think you misunderstand. The control itself is not drawing outside its window. When the window manager is asked to paint windows with certain classes, like 'menu' or 'tooltips', it (the window manager) renders the dropshadow and then the window. It's built in to the default window manager under Windows. There are replacement window managers available. Some may be open source and reveal their secrets. However, none of the windows is "painting outside itself."
How is the tooltips common control asking the Windows window manager to render a drop shadow around its window?
Ian Boyd
The bottom line is, it can't be a trick of the window manager, because the window manager is not being given the necessary hints to tell it to draw the drop shadow. Which means that the tooltip control is explicitly calling some kind of window manager api to manually render a drop-shadow. what api is it? i am intrigued.
Chris Becke
The window manager simply adds the CS_DROPSHADOW style to the window. In your post above you haven't enumerated the Class Styles, only the Window Styles. Were you to actually enumerate the Class Styles on a tooltip window with the 'Show shadows under menus' option checked you would see the CS_DROPSHADOW class style. With the option unchecked you wouldn't see it. Class Style are different than window styles. Why not write a sample program to test it? I don't have the time for it atm.
The tooltip (probably) uses the CS_DROPSHADOW class style (i don't know how to get an hWnd's class styles) to add the drop-shadow. The reason the shadow matches the window's non-rectangular shape because the window has a region applied (GetWindowRgn confirms this). So the answer, "You can't draw outside your window" is the correct answer. +1 and accepted.
Ian Boyd