走近VB.Net(三) 源码详解—运用颜色的初步探讨

走近 VB.Net( 三 ) 源码详解 — 运用颜色的初步探讨

 新建一个工程,加入以下控件


1.      label控件:label1,label2,labred ,labblue,labgreen


2.      picturebox控件:picturebox1


3.  button控件:Button1


设置form1的opacity属性为80%,设置透明的窗体


在office中抓取一幅取色图片存为bmp格式,并设为picturebox1的backgroundimage,即背景图片


Option Strict Off '关闭 strict off


Imports System.ComponentModel '引用族名


Imports System.Drawing '引用族名


Imports System.WinForms '引用族名


'下面的例程我将写出全部的族名与子类,是避免大家看得不明白,如果明白了意思,就可以使用基于省略的方式


 


Public Class Form1


    Inherits System.WinForms.Form '从System.WinForms.Form类引用到form1


    Public pixX, pixY As Integer '声明两个32位的变量,用public定义他在类中所有成员间共享


    Public Apr As Boolean = False '声明两个32位的变量,用public定义他在类中所有成员间共享并初始化他的值为false


    Public Sub New() '新建一个窗体


        MyBase.New() '调用


        Form1 = Me '定义me关键字的当前值为form1


        'This call is required by the Win Form Designer.


        InitializeComponent() '在这个下面写的代码等同于VB6的form_ load中所写的代码


        Call me_load() '你可以写一个子过程,在这里调用他,当然你完全可以写成别的过程名如me_beginform


        'TODO: Add any initialization after the InitializeComponent() call


    End Sub


    


    'Form overrides dispose to clean up the component list.


    Public Overrides Sub Dispose() '在这个下面写的代码等同于VB6的form_ unload中所写的代码


        MyBase.Dispose() '调用


        components.Dispose() 'unload组件


    End Sub


    


    


下面一段#Region " Windows Form Designer generated code "是不必看的,


我全部写在这里是为了您可以直接粘贴运行


#Region " Windows Form Designer generated code "


    


    'Required by the Windows Form Designer


    Private components As System.ComponentModel.Container


    


    Private WithEvents Label2 As System.WinForms.Label


    


    


    Private WithEvents Lab4 As System.WinForms.Label


    Private WithEvents Lab3 As System.WinForms.Label


    Private WithEvents Lab2 As System.WinForms.Label


    Private WithEvents LBblue As System.WinForms.Label


    Private WithEvents LBgreen As System.WinForms.Label


    Private WithEvents LBred As System.WinForms.Label


    


    Private WithEvents Button1 As System.WinForms.Button


    Private WithEvents Label1 As System.WinForms.Label


    Private WithEvents PictureBox1 As System.WinForms.PictureBox


    


    Dim WithEvents Form1 As System.WinForms.Form


    


    '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.


    Private Sub InitializeComponent()


        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))


        


        Me.components = New System.ComponentModel.Container()


        Me.LBblue = New System.WinForms.Label()


        Me.Lab2 = New System.WinForms.Label()


        Me.Label2 = New System.WinForms.Label()


        Me.Label1 = New System.WinForms.Label()


        Me.Lab3 = New System.WinForms.Label()


        Me.LBgreen = New System.WinForms.Label()


        Me.LBred = New System.WinForms.Label()


        Me.Lab4 = New System.WinForms.Label()


        Me.PictureBox1 = New System.WinForms.PictureBox()


        Me.Button1 = New System.WinForms.Button()


        


        '@design Me.TrayHeight = 0


        '@design Me.TrayLargeIcon = False


        '@design Me.TrayAutoArrange = True


        LBblue.Location = New System.Drawing.Point(216, 200)


        LBblue.Size = New System.Drawing.Size(112, 32)


        LBblue.BorderStyle = System.WinForms.BorderStyle.Fixed3D


        LBblue.TabIndex = 6


        LBblue.BackColor = System.Drawing.Color.Blue


        


        Lab2.Location = New System.Drawing.Point(8, 176)


        Lab2.Text = "R="


        Lab2.Size = New System.Drawing.Size(100, 23)


        Lab2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText


        Lab2.Font = New System.Drawing.Font("宋体", 12!, System.Drawing.FontStyle.Bold)


        Lab2.TabIndex = 7


        


        Label2.Location = New System.Drawing.Point(248, 8)


        Label2.Size = New System.Drawing.Size(48, 96)


        Label2.BorderStyle = System.WinForms.BorderStyle.Fixed3D


        Label2.TabIndex = 10


        


        Label1.Location = New System.Drawing.Point(192, 80)


        Label1.Size = New System.Drawing.Size(48, 88)


        Label1.BorderStyle = System.WinForms.BorderStyle.Fixed3D


        Label1.TabIndex = 1


        


        Lab3.Location = New System.Drawing.Point(112, 176)


        Lab3.Text = "G="


        Lab3.Size = New System.Drawing.Size(104, 24)


        Lab3.ForeColor = System.Drawing.SystemColors.ActiveCaptionText


        Lab3.Font = New System.Drawing.Font("宋体", 12!, System.Drawing.FontStyle.Bold)


        Lab3.TabIndex = 8


        


        LBgreen.Location = New System.Drawing.Point(112, 200)


        LBgreen.Size = New System.Drawing.Size(104, 32)


        LBgreen.BorderStyle = System.WinForms.BorderStyle.Fixed3D


        LBgreen.TabIndex = 5


        LBgreen.BackColor = System.Drawing.Color.Lime


        


        LBred.Location = New System.Drawing.Point(8, 200)


        LBred.Size = New System.Drawing.Size(104, 32)


        LBred.BorderStyle = System.WinForms.BorderStyle.Fixed3D


        LBred.TabIndex = 4


        LBred.BackColor = System.Drawing.Color.Red


        


        Lab4.Location = New System.Drawing.Point(216, 176)


        Lab4.Text = "B="


        Lab4.Size = New System.Drawing.Size(112, 24)


        Lab4.ForeColor = System.Drawing.SystemColors.ActiveCaptionText


        Lab4.Font = New System.Drawing.Font("宋体", 12!, System.Drawing.FontStyle.Bold)


        Lab4.TabIndex = 9


        


        PictureBox1.Cursor = System.Drawing.Cursors.Hand


        PictureBox1.BackgroundImage = CType(resources.GetObject("PictureBox1.BackgroundImage"), System.Drawing.Image)


        PictureBox1.Location = New System.Drawing.Point(8, 8)


        PictureBox1.Size = New System.Drawing.Size(176, 168)


        PictureBox1.TabIndex = 0


        PictureBox1.TabStop = False


        


        Button1.Location = New System.Drawing.Point(304, 48)


        Button1.ForeColor = System.Drawing.SystemColors.ControlLightLight


        Button1.Size = New System.Drawing.Size(24, 120)


        Button1.TabIndex = 2


        Button1.Text = "退出"


        Me.Text = "Form1"


        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)


        Me.BorderStyle = System.WinForms.FormBorderStyle.None


        Me.BackColor = System.Drawing.Color.Black


        Me.ClientSize = New System.Drawing.Size(344, 256)


        Me.Opacity = 0.8#


        


        Me.Controls.Add(Label2)


        Me.Controls.Add(Lab4)


        Me.Controls.Add(Lab3)


        Me.Controls.Add(Lab2)


        Me.Controls.Add(LBblue)


        Me.Controls.Add(LBgreen)


        Me.Controls.Add(LBred)


        Me.Controls.Add(Button1)


        Me.Controls.Add(Label1)


        Me.Controls.Add(PictureBox1)


    End Sub


    


#End Region


    上面一段#Region " Windows Form Designer generated code "是不必看的,


我全部写在这里是为了您可以直接粘贴运行


 


    Sub me_load()


        system.WinForms.MessageBox.show("欢迎使用我的第一个VB.Net程序", "微型取色器", messagebox.OK BitOr messagebox.IconAsterisk)


    End Sub


    


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) 'sender是发送数据的对象,e是按收参数的对象


        End '退出程序


    End Sub


    


    Protected Sub PictureBox1_Click(ByVal sender <SPAN s
Published At
Categories with Web编程
Tagged with
comments powered by Disqus