全局代码
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)
MessageBox.Show("你点击的是 : " & sender.Text)
End Sub
'图标双击事件
Public Sub ICON_DoubleClick(ByVal
sender As System.Object, ByVal e As System.EventArgs)
baseMainform.visible=True '设置主窗体显示
这个代码帮助中有的
End Sub
项目事件
AfterOpenProject
qat.Visible = False
AddHandler nfi.DoubleClick,
AddressOf Icon_DoubleClick '为通知区域图标添加双击事件
Dim tsmi1 As new
System.Windows.Forms.ToolStripMenuItem("菜单一",GetImage(projectpath
& "\BrowseMode.ico")) '定义一个菜单选项(带图标)
AddHandler tsmi1 .Click,
AddressOf Menu1_Click '为这个菜单选项添加点击事件
Dim tsmi2 As new
System.Windows.Forms.ToolStripMenuItem("菜单二") '定义一个菜单选项
AddHandler tsmi2 .Click,
AddressOf Menu1_Click '为这个菜单选项添加点击事件
Dim zcd1 As new
System.Windows.Forms.ToolStripMenuItem("子菜单1") '定义一个菜单选项
Dim zcd2 As new
System.Windows.Forms.ToolStripMenuItem("子菜单2") '定义一个菜单选项
tsmi2.DropDownItems.Add(zcd1) '把 "子菜单1" 添加为 "菜单二" 的子菜单
tsmi2.DropDownItems.Add(zcd2) '把 "子菜单2" 添加为 "菜单二" 的子菜单
Dim tsmi3 As new
System.Windows.Forms.ToolStripMenuItem("菜单三") '定义一个菜单选项
AddHandler tsmi3 .Click,
AddressOf Menu1_Click '为这个菜单选项添加点击事件
Dim ztsmi As new
System.Windows.Forms.ToolStripMenuItem("一级子菜单1") '定义一个菜单选项
AddHandler ztsmi .Click,
AddressOf Menu1_Click '为这个菜单选项添加点击事件
Dim ejzcd As new System.Windows.Forms.ToolStripMenuItem("二级子菜单1") '定义一个菜单选项
ztsmi.DropDownItems.Add(ejzcd
) '把"二级子菜单1" 添加为 "一级子菜单1"
的子菜单
tsmi3.DropDownItems.Add(ztsmi) '把 "一级子菜单1" 添加为 "菜单三" 的子菜单
cms.Items.Add(tsmi1) '为全局变量CMS 也就是右键菜单添加 "菜单一"
cms.Items.Add(tsmi2) '为全局变量CMS 也就是右键菜单添加 "菜单二"
cms.Items.Add(tsmi3) '为全局变量CMS 也就是右键菜单添加 "菜单三"
nfi.ContextMenuStrip = cms
nfi.Text = "我是Foxtable"
'鼠标移上去显示的文本
nfi.Icon = new Icon(ProjectPath
& "\001.ico") '图标地址
nfi.Visible = True '设置为显示
Forms("窗口1").show
以上命令实现了 把图标放在任务栏里。
学习了baseMainform.visible=False ,但只知道这个命令可以加给窗体里定义的按钮!
不知道如何通过系统主菜单的最小化按钮 到任务栏托盘?
请赐教!