Click-through on somewhat transparent forms

I'd like to have a form that's somewhat transparent that's always on top, and be able to click through it to the active application underneath, whatever happens to be "behind" this form.

I have an analog clock app that runs all the time, and I want to be able to access, for example, the minimize or maximize buttons of the application sitting behind my clock, which is semi-transparent.

I figured one way would be to figure out where on the screen the mouse clicked, find the active window, calculate the mouse location in relation to that window, and send that app the appropriate windows message. Don't think I'd want to do that, but that's an alternative. Any ideas?

[690 byte] By [codefund.com] at [2007-12-16]
# 1
One solution might be to experiment with the OS's "transparent window" style. Basically, your Form would override the CreateParams property and...

protected override CreateParams CreateParams
{
get
{
//OR in our transparent window style...
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x00000020/*WS_EX_TRANSPARENT*/;
return cp;
}
}

You may also need to adjust the ControlStyle depending on how your painting logic works...

SetStyle(ControlStyles.Opaque,true);

Warning: working with Transparent windows may be tricky, as it's not obvious what should be painting and which messages should be sent where. I would also recommend reading up on this extended window style via http://msdn.microsoft.com/

Good luck,
-Fred

codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
Cool. I'll check it out!
codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...