|
bsp; 'TODO: Add any initialization after the InitializeComponent() call
'this form isn't used directly so hide it immediately
Me.Hide()
'setup the tray icon
Initializenotifyicon()
End Sub
Private Sub Initializenotifyicon()
'setup the default icon
notifyicon = New System.Windows.Forms.NotifyIcon()
NotifyIcon.Icon = mIconA
NotifyIcon.Text = "Right Click for the menu"
NotifyIcon.Visible = True
mIconDisplayed = True
'Insert all MenuItem objects into an array and add them to
'the context menu simultaneously
Dim mnuItms(3) As MenuItem
mnuItms(0) = New MenuItem("Show Form...", New EventHandler(AddressOf Me.ShowFormSelect))
mnuItms(0).DefaultItem = True
mnuItms(1) = New MenuItem("Toggle Image", New EventHandler(AddressOf Me.ToggleImageSelect))
mnuItms(2) = New MenuItem("-")
mnuItms(3) = New MenuItem("Exit", New EventHandler(AddressOf Me.ExitSelect))
Dim notifyiconMnu As ContextMenu = New ContextMenu(mnuItms)
notifyicon.ContextMenu = notifyiconMnu
End Sub
Public Sub ShowFormSelect(ByVal sender As Object, ByVal e As System.EventArgs)
'Display the settings dialog
Dim SettingsForm As New SettingsForm()
SettingsForm.ShowDialog()
End Sub
Public Sub ToggleImageSelect(ByVal sender As Object, ByVal e As System.EventArgs)
'called when the user selects the 'Toggle Image' context menu
'determine which icon is currently visible and switch it
If mIconDisplayed Then
'called when the user selects the 'Show Form' context menu
NotifyIcon.Icon = mIconB
NotifyIcon.Text = "Sad"
mIconDisplayed = False
Else
NotifyIcon.Icon = mIconA
NotifyIcon.Text = "Happy"
mIconDisplayed = True
End If
End Sub
Public Sub ExitSelect(ByVal sender As Object, ByVal e As System.EventArgs)
'called when the user selects the 'Exit' context menu
'hide the tray icon
NotifyIcon.Visible = False
'close up
Me.Close()
End Sub
'Form overrides dispose to clean up the component list.
Public Overloads Overrides Sub Dispose()
MyBase.Dispose()
components.Dispose()
End Sub
图标文件你自己准备了,如果成功你可以看到有关NotifyIcond的各种功能了。
13. 如何修改控制窗体的尺寸和长宽尺寸.
主要是修改Winform的Size, Width 和Height属性。同样它们都是可以在设计和运行时刻进行修改和设置。
Form1.Size = New System.Drawing.Size(100, 100) ( VB.NET )
Form1.Width += 100 (VB.NET )
Form1.Height -= 20 (VB.NET )
14. 如何建立一个Windows Explorer风格的窗体.
1.建立一个新的Windows Application
2.从Toolbox窗口拖一个TreeView控件、、一个Splitterk控件、一个ListView控件,分别在属性窗口中设置TreeView的Dock属性为::Left;设置ListView控件的Dock属性为:Fill
3: F5 运行
上一页 [1] [2] [3] 下一页
|