有没有一种简单的方法在VB .NET应用程序中执行透明表单?

时间:2008-08-31 02:05:04

标签: vb.net transparency

我正在编写一个简单的应用程序,它会在屏幕的一个角落放置一个小小的形状,并自行更新。

我真的很喜欢这种形式透明,并且透明度可由用户配置。

有没有简单的方法来实现这个目标?

4 个答案:

答案 0 :(得分:4)

您可以尝试使用表单的Opacity属性。以下是MSDN页面中的相关代码段:

private Sub CreateMyOpaqueForm()
   ' Create a new form.
   Dim form2 As New Form()
   ' Set the text displayed in the caption.
   form2.Text = "My Form"
   ' Set the opacity to 75%.
   form2.Opacity = 0.75
   ' Size the form to be 300 pixels in height and width.
   form2.Size = New Size(300, 300)
   ' Display the form in the center of the screen.
   form2.StartPosition = FormStartPosition.CenterScreen

   ' Display the form as a modal dialog box.
   form2.ShowDialog()
End Sub

答案 1 :(得分:0)

您可以设置Form.Opacity属性。它应该做你想要的。

答案 2 :(得分:0)

在页面加载时设置Form.Opacity = 0.0

我在大约一年前设置的东西就像你在app上谈论的那样。使用While循环和小Sleep,您可以设置一个很好的淡入淡出效果。

答案 3 :(得分:0)

我不确切地知道透明的含义,但是如果你使用WPF,你可以在表单上设置AllowTransparency = True,然后删除表单的样式/边框,然后将背景设置为具有零alpha通道。然后,您可以在表单上绘制所有想要的内容,背景将是透明的,其他内容将完全可见。此外,您可以将背景设置为低不透明度图层,这样您就可以看到表单。