以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]自定义窗体点关闭时如何关闭程序 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=44311) |
||||
-- 作者:jnletao -- 发布时间:2013/12/27 15:29:00 -- [求助]自定义窗体点关闭时如何关闭程序 自定义窗体点关闭时如何关闭程序
全局代码 Public DataStr As String = "" Public ButtonYes As Boolean = False Public Class FormData Inherits System.Windows.Forms.Form Private Sub ButtonOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click \'确定 If ComboBoxData.Text.Trim.Length < 1 Then Messagebox.Show("请选择使用账套!","账套选择",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If DataStr = ComboBoxData.Text ButtonYes = True Me.Close() End Sub Private Sub FormData_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.ComboBoxData = New System.Windows.Forms.ComboBox Me.Label1 = New System.Windows.Forms.Label Me.ButtonOK = New System.Windows.Forms.Button Me.SuspendLayout() \' \'ComboBoxData \' Me.ComboBoxData.FormattingEnabled = True Me.ComboBoxData.Location = New System.Drawing.Point(85, 27) Me.ComboBoxData.Name = "ComboBoxData" Me.ComboBoxData.Size = New System.Drawing.Size(156, 20) Me.ComboBoxData.TabIndex = 0 \' \'Label1 \' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(12, 30) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(65, 12) Me.Label1.TabIndex = 1 Me.Label1.Text = "可选账套:" \' \'ButtonOK \' Me.ButtonOK.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte)) Me.ButtonOK.Location = New System.Drawing.Point(154, 80) Me.ButtonOK.Name = "ButtonOK" Me.ButtonOK.Size = New System.Drawing.Size(87, 29) Me.ButtonOK.TabIndex = 2 Me.ButtonOK.Text = "确定" Me.ButtonOK.UseVisualStyleBackColor = True \' \'FormData \' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(253, 121) Me.Controls.Add(Me.ButtonOK) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.ComboBoxData) Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "FormData" Me.Text = "请选择帐套" Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents ComboBoxData As System.Windows.Forms.ComboBox Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents ButtonOK As System.Windows.Forms.Button End Class BeforeOpenProject Dim frm As New FormData frm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen frm.TopMost = True \'或 e.HideSplashForm = True frm.ShowDialog() \'模式打开 If ButtonYes Then \'你的策略 msgbox(DataStr) End If |
||||
-- 作者:Bin -- 发布时间:2013/12/27 15:42:00 -- 添加FormClosed 事件执行 Syscmd.Project.Exit(True) |
||||
-- 作者:逛逛 -- 发布时间:2013/12/27 17:47:00 -- 把全局代码中你想终止程序的 Me.Close() 改成 Application.Exit()
应该在 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) 中 [此贴子已经被作者于2013-12-27 17:48:07编辑过]
|
||||
-- 作者:包头123 -- 发布时间:2013/12/27 17:49:00 -- 这么复杂啊。 |