VS2005如何制作(VB)不规则窗体?

来源:百度知道 编辑:UC知道 时间:2024/06/24 17:09:09
就以三角形为例吧?

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
'根据窗体尺寸的改变从新设置窗体的区域
Dim outer_rect As Rectangle
Dim inner_rect As Rectangle
Dim combined_rgn As Region
If WindowState = FormWindowState.Minimized Then Exit Sub
'创建方块
outer_rect = New Rectangle(0, 0, Me.Width, Me.Height)
inner_rect = New Rectangle(20, 40, ClientSize.Width * 0.9, ClientSize.Height * 0.9)
'创建区域
combined_rgn = New Region(outer_rect)
combined_rgn.Xor(inner_rect)
'设置窗体区域
Me.Region = combined_rgn
End Sub
这是个方块的例子。

在VB2005中可以在窗体的属性表里面找到窗体的有关透明的属性设置,只要添加一张图片,并且把透明色改为要是窗体需要透明的地方颜色就可以了。之后改变窗体的边框就完美无缺了。