日期:2012-10-28  浏览次数:20497 次

走近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.ActiveCapti