C# transparent border for borderless form

前端 未结 2 889
闹比i
闹比i 2021-01-01 03:33

I\'m creating a borderless form and I want to add a custom border to it. When I add the background for the form however, it doesn\'t show well, and it is not transparent. <

2条回答
  •  有刺的猬
    2021-01-01 03:47

    There is a way to use a semi-transparent (alpha) image as the form background in WinForms, as described in this article: A lovely goldfish desktop pet (using alpha-PNG and GDI+).

    It uses native interop to blend the image with the desktop.

    Also, check out UpdateLayeredWindow function (User32.dll) on pinvoke.net. There is also an example how to use it.

    [Edit]

    There is also a link on pinvoke.net to Mike Swanson's blog article about the same subject. It uses the same code as described in mentioned links, but it's a VS project which does exactly what OP wants: a splash form with a semitransparent PNG image as a background.

提交回复
热议问题