'全局代码
Public _Sys_Sw As String '界面开关状态
Public Dim nfi As new System.Windows.Forms.NotifyIcon '定义通知区域小图标
Public Dim cms As new System.Windows.Forms.ContextMenuStrip '定义右键菜单
'菜单按钮点击事件
Public Sub Menu1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Result As DialogResult
Result = MessageBox.Show("程序正在运行,你确定退出该程序?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Syscmd.Project.Exit
Return '这个要加上,因为既然要退出,就不应该再执行后面的初始化代码了,否则会出错
End If
End Sub
'图标MouseDown事件
Public Sub ICON_MouseDown(ByVal sender As System.Object, ByVal e As System.EventArgs)
If MouseButton =MouseButtons.Right Then '假定按下的是鼠标右键
Else If MouseButton =MouseButtons.Left Then '假定按下的是鼠标左键
If baseMainform.visible=True Then
baseMainform.visible=False '设置主窗体隐藏 这个代码帮助中有的
If Forms("QQServer").opened Then
Forms("QQServer").close
End If
ElseIf baseMainform.visible=False Then
baseMainform.visible=True '设置主窗体显示 这个代码帮助中有的
_Sys_Sw="开"
Forms("QQServer").show
End If
End If
End Sub
'项目事件AfterOpenProject
TableCaptionVisible = False '隐藏表标题
'AddHandler nfi.Click, AddressOf Icon_Click '为通知区域图标添加单击事件
AddHandler nfi.MouseDown, AddressOf Icon_MouseDown '为通知区域图标添加MouseDown事件
Dim tsmi1 As new System.Windows.Forms.ToolStripMenuItem("退出") '定义一个菜单选项
AddHandler tsmi1.Click, AddressOf Menu1_Click '为这个菜单选项添加点击事件
cms.Items.Add(tsmi1) '为全局变量CMS 也就是右键菜单添加 "退出"
nfi.ContextMenuStrip = cms
nfi.Text = "我是QQServer" '鼠标移上去显示的文本
nfi.Icon = new Icon(ProjectPath & "\001.ico") '图标地址
nfi.Visible = True '设置为显示
Forms("QQServer").show