|
楼主 |
发表于 2007-2-12 10:42:10
|
显示全部楼层
<p></p><p> Private Sub InitializeComponent()Sub InitializeComponent()<br/> Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(loginForm))<br/> Me.lblUserPwd = New System.Windows.Forms.Label<br/> Me.lblUserName = New System.Windows.Forms.Label<br/> Me.txtUserName = New System.Windows.Forms.TextBox<br/> Me.txtUserPwd = New System.Windows.Forms.TextBox<br/> Me.btnSubmit = New System.Windows.Forms.Button<br/> Me.btnExit = New System.Windows.Forms.Button<br/> Me.Label1 = New System.Windows.Forms.Label<br/> Me.Label2 = New System.Windows.Forms.Label<br/> Me.btnCancel = New System.Windows.Forms.Button<br/> Me.Label3 = New System.Windows.Forms.Label<br/> Me.SuspendLayout()<br/> '<br/> 'lblUserPwd<br/> '<br/> Me.lblUserPwd.Location = New System.Drawing.Point(46, 176)<br/> Me.lblUserPwd.Name = "lblUserPwd"<br/> Me.lblUserPwd.Size = New System.Drawing.Size(52, 23)<br/> Me.lblUserPwd.TabIndex = 0<br/> Me.lblUserPwd.Text = "密码:"<br/> Me.lblUserPwd.TextAlign = System.Drawing.ContentAlignment.MiddleCenter<br/> '<br/> 'lblUserName<br/> '<br/> Me.lblUserName.Location = New System.Drawing.Point(46, 128)<br/> Me.lblUserName.Name = "lblUserName"<br/> Me.lblUserName.Size = New System.Drawing.Size(52, 23)<br/> Me.lblUserName.TabIndex = 1<br/> Me.lblUserName.Text = "帐号:"<br/> Me.lblUserName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter<br/> '<br/> 'txtUserName<br/> '<br/> Me.txtUserName.BackColor = System.Drawing.SystemColors.Info<br/> Me.txtUserName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle<br/> Me.txtUserName.Location = New System.Drawing.Point(110, 128)<br/> Me.txtUserName.Name = "txtUserName"<br/> Me.txtUserName.Size = New System.Drawing.Size(151, 21)<br/> Me.txtUserName.TabIndex = 3<br/> Me.txtUserName.Text = ""<br/> '<br/> 'txtUserPwd<br/> '<br/> Me.txtUserPwd.BackColor = System.Drawing.SystemColors.Info<br/> Me.txtUserPwd.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle<br/> Me.txtUserPwd.Location = New System.Drawing.Point(110, 176)<br/> Me.txtUserPwd.Name = "txtUserPwd"<br/> Me.txtUserPwd.PasswordChar = Microsoft.VisualBasic.ChrW(42)<br/> Me.txtUserPwd.Size = New System.Drawing.Size(151, 21)<br/> Me.txtUserPwd.TabIndex = 4<br/> Me.txtUserPwd.Text = ""<br/> '<br/> 'btnSubmit<br/> '<br/> Me.btnSubmit.BackColor = System.Drawing.SystemColors.ActiveBorder<br/> Me.btnSubmit.Cursor = System.Windows.Forms.Cursors.Hand<br/> Me.btnSubmit.ForeColor = System.Drawing.SystemColors.InfoText<br/> Me.btnSubmit.Location = New System.Drawing.Point(56, 216)<br/> Me.btnSubmit.Name = "btnSubmit"<br/> Me.btnSubmit.TabIndex = 5<br/> Me.btnSubmit.Text = "登录"<br/> '<br/> 'btnExit<br/> '<br/> Me.btnExit.BackColor = System.Drawing.SystemColors.ActiveBorder<br/> Me.btnExit.Cursor = System.Windows.Forms.Cursors.Hand<br/> Me.btnExit.Location = New System.Drawing.Point(141, 216)<br/> Me.btnExit.Name = "btnExit"<br/> Me.btnExit.TabIndex = 6<br/> Me.btnExit.Text = "退出"<br/> '<br/> 'Label1<br/> '<br/> Me.Label1.Font = New System.Drawing.Font("Impact", 17.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))<br/> Me.Label1.Location = New System.Drawing.Point(38, 64)<br/> Me.Label1.Name = "Label1"<br/> Me.Label1.Size = New System.Drawing.Size(256, 32)<br/> Me.Label1.TabIndex = 6<br/> Me.Label1.Text = "TEST"<br/> '<br/> 'Label2<br/> '<br/> Me.Label2.BackColor = System.Drawing.SystemColors.ControlText<br/> Me.Label2.ForeColor = System.Drawing.SystemColors.HighlightText<br/> Me.Label2.Location = New System.Drawing.Point(0, 0)<br/> Me.Label2.Name = "Label2"<br/> Me.Label2.Size = New System.Drawing.Size(320, 24)<br/> Me.Label2.TabIndex = 7<br/> Me.Label2.Text = "系统登录"<br/> Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter<br/> '<br/> 'btnCancel<br/> '<br/> Me.btnCancel.BackColor = System.Drawing.SystemColors.ActiveBorder<br/> Me.btnCancel.Cursor = System.Windows.Forms.Cursors.Hand<br/> Me.btnCancel.Location = New System.Drawing.Point(225, 215)<br/> Me.btnCancel.Name = "btnCancel"<br/> Me.btnCancel.TabIndex = 10<br/> Me.btnCancel.Text = "取消"<br/> '<br/> 'Label3<br/> '<br/> Me.Label3.ForeColor = System.Drawing.Color.Red<br/> Me.Label3.Location = New System.Drawing.Point(163, 262)<br/> Me.Label3.Name = "Label3"<br/> Me.Label3.Size = New System.Drawing.Size(149, 16)<br/> Me.Label3.TabIndex = 11<br/> Me.Label3.Text = "为保证系统安全,请先登录"<br/> '<br/> 'loginForm<br/> '<br/> Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)<br/> Me.BackColor = System.Drawing.SystemColors.ActiveBorder<br/> Me.ClientSize = New System.Drawing.Size(319, 284)<br/> Me.Controls.Add(Me.Label3)<br/> Me.Controls.Add(Me.btnCancel)<br/> Me.Controls.Add(Me.Label2)<br/> Me.Controls.Add(Me.Label1)<br/> Me.Controls.Add(Me.btnExit)<br/> Me.Controls.Add(Me.txtUserPwd)<br/> Me.Controls.Add(Me.txtUserName)<br/> Me.Controls.Add(Me.btnSubmit)<br/> Me.Controls.Add(Me.lblUserName)<br/> Me.Controls.Add(Me.lblUserPwd)<br/> Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None<br/> Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)<br/> Me.MaximizeBox = False<br/> Me.MinimizeBox = False<br/> Me.Name = "loginForm"<br/> Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide<br/> Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen<br/> Me.Tag = "登录"<br/> Me.Text = "TEST--系统登录"<br/> Me.ResumeLayout(False)<br/> End Sub<br/>#End Region<br/> Private Sub loginForm_Load()Sub loginForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br/> txtUserName.Focus()<br/> ' btnCancel.Visible = False<br/> End Sub<br/> Private Sub btnExit_Click()Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click<br/> Application.Exit()<br/> End Sub<br/> Private Sub btnSubmit_Click()Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click<br/> '调用loginValidator组件<br/> Dim validator As New Validator<br/> validator.vUsername = txtUserName.Text.Trim<br/> validator.vUserpwd = txtUserPwd.Text.Trim<br/> If (validator.validate() = True) Then<br/> Me.Close()<br/> Else<br/> MessageBox.Show("帐号或密码错误,请重试!", "验证错误", MessageBoxButtons.OK, MessageBoxIcon.Warning)<br/> End If<br/> End Sub<br/> Private Sub btnCancel_Click()Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)<br/> Me.Dispose()<br/> End Sub<br/> Private Sub btnCancel_Click_1()Sub btnCancel_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click<br/> Me.Close()<br/> End Sub<br/>End Class<br/>关于在.NET中使用COM组件:.NET可以向后兼容,并支持了COM和ActiveX对象等早期版本的应用程序。在.NET中使用COM等很有趣,.NET创建一个包将它们包装起来,而它们之间的交互就是通过这个包装来进行的,这个包就叫做运行时可呼叫包装(RCW)。可以直接使用COM,也可以先转换成.NET程序集后再使用。<br/>1、直接使用COM组件是通过Add Reference来实现的,这种方法通过RCW来包装。缺点:无法放到 GAC中,不能重用。<br/> 2、通过转换成.NET程序集来使用,是通过利用 tlbimp 命令行工具来实现的,语法:<br/> tlbimp COMName.dll /out:Comp.dll /namespace:myNS /asmVersion: myVersion /reference:refname<br/> 第一个为COM的名称,第二个为要生成的.NET组件名称,第三个为要生成的名称空间,第四个为 版本号,第四个指定引用的文件名。 </p> |
|