如何在VB.Net中制作阴影表单? [英] How To Make A Shadow Form In VB.Net?

查看:186
本文介绍了如何在VB.Net中制作阴影表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VB.net中,我使用了代码:



In VB.net, I Have Use An Code :

'This Is The Code :

'=========================================================

Dim m_Bitmap As New Bitmap(Me.Width, Me.Height)
        Using g As Graphics = Graphics.FromImage(m_Bitmap)
            g.CopyFromScreen(Me.Location, Point.Empty, Me.Size)
            g.DrawImage(My.Resources.name_of_your_background_image_here, 0, 0, Me.Width, Me.Height)
        End Using
        Me.BackgroundImage = m_Bitmap


'=========================================================
'Copy It.
'At The Load, And Be Come
'Public Class Form1
'
'    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'        Dim m_Bitmap As New Bitmap(Me.Width, Me.Height)
'       Using g As Graphics = Graphics.FromImage(m_Bitmap)
'            g.CopyFromScreen(Me.Location, Point.Empty, Me.Size)
'            g.DrawImage(My.Resources.name_of_your_background_image_here, 0, 0, Me.Width, Me.Height)
'        End Using
'        Me.BackgroundImage = m_Bitmap
'    End Sub
'End Class





但是此代码有问题

刚刚打开此链接



https://lh3.googleusercontent.com/-2n8GtA086Yw/Unto19HNJ-I/AAAAAAAAAeQ/SykaIuJj4aA/w610-h339-no/Untitled。 png.png

推荐答案

访问这里....





让你的表格掉落阴影 [ ^ ]
visit here....


Let Your Form Drop a Shadow[^]


公共类Form1





私人sd作为新的frmShadow(我)

Private Sub Form1_Load(ByVal sender As Object,ByVal e As System.EventArgs)Handles Me.Load

sd.Location = Me.Location

sd.shWidth = Me.Width - 10

sd.shHeight = Me.Height - 10

sd.CreateShadow()

End Sub



Private Sub Form1_Move(ByVal发送呃作为对象,ByVal e As System.EventArgs)处理我。移动

sd.Location = Me.Location

End Sub

End Class







公共类frmShadow

私有m_width为整数= 0

私有m_Height As Integer = 0

私有m_color As System.Drawing.Color



Public Sub New(ByVal所有者作为控制)

InitializeComponent()

Me.Opacity = 0.5

Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.Owner =所有者

结束子



公共财产shWidth()作为整数

获取

返回m_width

结束获取

设置(ByVal值为整数)

m_width = value + 5

Me.Width = m_width

结束套件

结束物业



公共财产shHeight()作为整数

获取

返回m_Height

结束获取

Set( ByVal值As Integer)

m_Height = value + 5

Me.Height = m_Height

结束集

结束物业



公共物业shColor()As System.Drawing.Color

获取

返回m_color

结束获取

设置(ByVal值为System.Drawing.Color)

m_color = value

Me.BackColor = value

结束套件

结束物业



Public Sub CreateShadow()

Dim reg as New Region(New Rectangle(0,0,m_width,m_Height))

Dim oPath As New System.Drawing.Drawing2D.GraphicsPath

Dim olPath As New System。 Drawing.Drawing2D.GraphicsPath

Dim obPat h As New System.Drawing.Drawing2D.GraphicsPath

Dim otPath As New System.Drawing.Drawing2D.GraphicsPath

Dim shpath()As Point = {New Point(m_width - 5,5),新点(m_width,10),新点(m_width,m_Height - 5),新点(m_width - 5,m_Height),新点(10,m_Height),新点(5,m_Height - 5) ,新点(m_width - 5,m_Height - 5)}



oPath.AddLines(shpath)

reg.Intersect(oPath)< br $>


olPath.AddArc(3,Me.Height - 7,8,7,45,180)

reg.Union(olPath)< br $> b $ b

obPath.AddArc(m_width - 7,m_Height - 7,7,7,315,180)

reg.Union(obPath)< br $>


otPath.AddArc(m_width - 7,3,7,8,225,180)

reg.Union(otPath)



Me.Region = reg

Me.Show()

End Sub

< br $>




结束班
Public Class Form1


Private sd As New frmShadow(Me)
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
sd.Location = Me.Location
sd.shWidth = Me.Width - 10
sd.shHeight = Me.Height - 10
sd.CreateShadow()
End Sub

Private Sub Form1_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move
sd.Location = Me.Location
End Sub
End Class



Public Class frmShadow
Private m_width As Integer = 0
Private m_Height As Integer = 0
Private m_color As System.Drawing.Color

Public Sub New(ByVal owner As Control)
InitializeComponent()
Me.Opacity = 0.5
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.Owner = owner
End Sub

Public Property shWidth() As Integer
Get
Return m_width
End Get
Set(ByVal value As Integer)
m_width = value + 5
Me.Width = m_width
End Set
End Property

Public Property shHeight() As Integer
Get
Return m_Height
End Get
Set(ByVal value As Integer)
m_Height = value + 5
Me.Height = m_Height
End Set
End Property

Public Property shColor() As System.Drawing.Color
Get
Return m_color
End Get
Set(ByVal value As System.Drawing.Color)
m_color = value
Me.BackColor = value
End Set
End Property

Public Sub CreateShadow()
Dim reg As New Region(New Rectangle(0, 0, m_width, m_Height))
Dim oPath As New System.Drawing.Drawing2D.GraphicsPath
Dim olPath As New System.Drawing.Drawing2D.GraphicsPath
Dim obPath As New System.Drawing.Drawing2D.GraphicsPath
Dim otPath As New System.Drawing.Drawing2D.GraphicsPath
Dim shpath() As Point = {New Point(m_width - 5, 5), New Point(m_width, 10), New Point(m_width, m_Height - 5), New Point(m_width - 5, m_Height), New Point(10, m_Height), New Point(5, m_Height - 5), New Point(m_width - 5, m_Height - 5)}

oPath.AddLines(shpath)
reg.Intersect(oPath)

olPath.AddArc(3, Me.Height - 7, 8, 7, 45, 180)
reg.Union(olPath)

obPath.AddArc(m_width - 7, m_Height - 7, 7, 7, 315, 180)
reg.Union(obPath)

otPath.AddArc(m_width - 7, 3, 7, 8, 225, 180)
reg.Union(otPath)

Me.Region = reg
Me.Show()
End Sub



End Class


这篇关于如何在VB.Net中制作阴影表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆