Hi
I want to create a c# application with multiple windows that are all transparent with some text on.
The tricky part is making these forms sit on top of the desktop but under the desktop icons. Is this possible?
Hi
I want to create a c# application with multiple windows that are all transparent with some text on.
The tricky part is making these forms sit on top of the desktop but under the desktop icons. Is this possible?
Just making the window transparent is very straight forward:
this.BackColor = Color.Fuchsia;
this.TransparencyKey = Color.Fuchsia;
You can do something like this to make it so you can still interact with the desktop or anything else under your window:
public const int WM_NCHITTEST = 0x84;
public const int HTTRANSPARENT = -1;
protected override void WndProc(ref Message message)
{
if ( message.Msg == (int)WM_NCHITTEST )
{
message.Result = (IntPtr)HTTRANSPARENT;
}
else
{
base.WndProc( ref message );
}
}
Thanks for the tips Jeff. Its still not quite what I'm after. I would effectively like the window to appear as if it was part of the desktop so icons could sit on top of my form.
Maybe there is a different way to do it. Can I actually draw text and graphics directly on to the desktop?
The method described above by Jeff Hillman is effective in making the window transparent, which should give you the ability to have it appear as though it's part of the desktop (which you mentioned is your goal.
One issue you may run into, which I have just recently run into as well, is drawing to the window with any anti-aliasing flags set. Specifically, using DrawText, any text that's rendered with anti-aliasing flags set is rendered as though the background were NOT transparent. The end result is that you get text with a slight off-color border around it. I'm sure this would hold true for anything else as well, though I haven't tried.
Are there any thoughts on how to resolve that?