Foxtable(狐表)用户栏目专家坐堂 → [求助]自定义窗体点关闭时如何关闭程序


  共有5617人关注过本帖树形打印复制链接

主题:[求助]自定义窗体点关闭时如何关闭程序

帅哥哟,离线,有人找我吗?
jnletao
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:943 积分:7802 威望:0 精华:0 注册:2013/7/7 13:37:00
[求助]自定义窗体点关闭时如何关闭程序  发帖心情 Post By:2013/12/27 15:29:00 [只看该作者]

自定义窗体点关闭时如何关闭程序
 下载信息  [文件大小:   下载次数: ]
点击浏览该文件:启动时切换数据源.foxdb

全局代码

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
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2013/12/27 15:42:00 [只看该作者]

添加FormClosed 事件执行

Syscmd.Project.Exit(True)


 回到顶部
帅哥哟,离线,有人找我吗?
逛逛
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:1693 积分:12135 威望:0 精华:7 注册:2013/7/11 10:52:00
  发帖心情 Post By: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
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1049 积分:8150 威望:0 精华:0 注册:2011/10/11 11:13:00
  发帖心情 Post By:2013/12/27 17:49:00 [只看该作者]

这么复杂啊。

 回到顶部