⽤VB绘制漂亮的splash界⾯学习过程中看到的⽤VB绘制漂亮的splash界⾯,收藏如下:(效果可见相册中的收藏)
Option Explicit On
Option Strict On
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Convert
Public Class frmSplash
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
array在vb什么意思啊If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents tmrSplash As System.Windows.Forms.Timer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Meponents = New System.ComponentModel.Container()
'
'tmrSplash
'
'
'frmSplash
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(512, 357)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.Name = "frmSplash"
Me.Text = "Form1"
End Sub
#End Region
' The Paint event fires when the form is rendered. Thus, we
' perform the drawing operations in this event handler. Note that
' the second argument (e), contains a reference to an instance
' of the Graphics class.
Private Sub frmSplash_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
' Draw the first background rectangle using a HatchBrush.
Dim recHatchFill As New Rectangle(0, 0, _
Me.ClientSize.Width, Me.ClientSize.Height)
Dim hbCurrent As New HatchBrush( _
HatchStyle.Percent90, Color.Gray)
e.Graphics.FillRectangle(hbCurrent, recHatchFill)
' All custom brushes should be explicitly disposed.
hbCurrent.Dispose()
' Draw the line along the bottom of the form.
Dim pntStart As New Point(10, Me.ClientSize.Height - 10)
Dim pntEnd As New Point(Me.ClientSize.Width - 10, Me.ClientSize.Height - 10)        Dim penLine As New Pen(Color.SkyBlue, 3)
e.Graphics.DrawLine(penLine, pntStart, pntEnd)
penLine.Dispose()
' Draw a rectangle just above the line drawn in the
' preceding statements.
Dim pntOutline As New Point(10, 260)
Dim sizOutline As New Size(Me.ClientSize.Width - 20, 80)
Dim penOutline As New Pen(Color.LightSkyBlue, 2)
Dim recOutline As New Rectangle(pntOutline, sizOutline)
e.Graphics.DrawRectangle(penOutline, recOutline)
' All custom pens must be explicitly disposed.
penOutline.Dispose()
' Create a LinearGradentBrush above the preceding rectangle.
Dim recLgb As New Rectangle(10, 10, Me.ClientSize.Width - 20, 235)
Dim lgbRectangle As New LinearGradientBrush(recLgb, _
Color.AliceBlue, Color.SteelBlue, _
LinearGradientMode.Horizontal)
e.Graphics.FillRectangle(lgbRectangle, recLgb)
' All custom brushes must be explicitly disposed.
lgbRectangle.Dispose()
' Create a font and then display text inside of a bounding
' Rectangle.
Dim recText As New Rectangle(1, 1, 390, 80)
Dim fntCurrent As New Font("Arial", 48, FontStyle.Bold)
Dim lgbCurrent As New LinearGradientBrush(recText, _
Color.AliceBlue, Color.SteelBlue, LinearGradientMode.Horizontal)
e.Graphics.DrawString("Chapter 12", fntCurrent, lgbCurrent, _
10, 260)
' Explicitly dispose of the custom font and the LinearGradientBrush.
fntCurrent.Dispose()
lgbCurrent.Dispose()
' Create a filled rectangle, and draw a border around that
' rectangle.
Dim recSolidFill As New Rectangle(50, 50, 100, 100)
e.Graphics.FillRectangle(Brushes.Thistle, recSolidFill)
e.Graphics.DrawRectangle(Pens.Black, recSolidFill)
' Fill and draw a border surrounding a polygon.
Dim pnt1 As New Point(100, 100)
Dim pnt2 As New Point(150, 200)
Dim pnt3 As New Point(50, 200)
Dim pntArray() As Point = {pnt1, pnt2, pnt3}
e.Graphics.FillPolygon(Brushes.Plum, pntArray)
e.Graphics.DrawPolygon(Pens.Black, pntArray)
' Create an ellipse. Fill the ellipse and draw a border
' around it.
Dim recCircle As New Rectangle(125, 125, 100, 100)
e.Graphics.FillEllipse(Brushes.DarkOrchid, recCircle)
e.Graphics.DrawEllipse(Pens.Black, recCircle)
' Create a pie slice. Fill the pie slice with a named
' brush, and then draw a black line to surround that same
' pie slice. Note that named brushes need not be explictly
' disposed
e.Graphics.FillPie(Brushes.Purple, recCircle, 0, 45)
e.Graphics.DrawPie(Pens.Black, recCircle, 0, 45)
' Load and display an image inside of a rectangle.
Dim imgCurrent As Image
imgCurrent = Image.FromFile("../../Data/CourseLogo.bmp")
Dim recImage As New Rectangle(300, 175, imgCurrent.Size.Width, imgCurrent.Size.Height)
e.Graphics.DrawImage(imgCurrent, recImage)
End Sub
' Close the form.
Private Sub tmrSplash_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSplash.Tick        Me.Close()
End Sub
End Class

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。