Windows Mobile 窗口最小化到系统状态栏怎么用vb.net实现?

jesperzx 2010-09-01 06:13:29
本人只懂得vb,网上多数资料关于这个的都是用c#的,请各位大虾帮忙,提供有关代码,万分感谢。
...全文
69 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
SongQues 2010-10-09
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 songques 的回复:]

引用 3 楼 thestronger 的回复:

引用 1 楼 songques 的回复:

1楼的,不是有现成的NotifyIcon控件吗?


他不要VB.net么!
[/Quote]

报什么错误?
beyondma 2010-10-01
  • 打赏
  • 举报
回复
c#和VB有什么大区别吗?只是设一下WINDOWSTATE不就好了吗?
jlabc 2010-09-30
  • 打赏
  • 举报
回复
学习,支持!
jesperzx 2010-09-30
  • 打赏
  • 举报
回复
vc#的也可以,有没有这个例子阿
jesperzx 2010-09-03
  • 打赏
  • 举报
回复
vb2005好像没有notifyicon控件阿
jesperzx 2010-09-03
  • 打赏
  • 举报
回复
请问你这个程序是在什么环境下运行的阿,我复制过去用vb2005,还有很多错误的,是不是还要引用之类呢
SongQues 2010-09-03
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 thestronger 的回复:]

引用 1 楼 songques 的回复:

1楼的,不是有现成的NotifyIcon控件吗?
[/Quote]

他不要VB.net么!
thestronger 2010-09-02
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 songques 的回复:]
[/Quote]
1楼的,不是有现成的NotifyIcon控件吗?
SongQues 2010-09-02
  • 打赏
  • 举报
回复

Public Class NotifyIcon
' Events
Public Custom Event Click As EventHandler
AddHandler(ByVal value As EventHandler)
Me.Click = Delegate.Combine(Me.Click, value)
End AddHandler
RemoveHandler(ByVal value As EventHandler)
Me.Click = Delegate.Remove(Me.Click, value)
End RemoveHandler
End Event

' Methods
Public Sub New()
Me.messageWindow = New MyMessageWindow(Me)
Me.messageWindow.uID = Me.uID
End Sub

Public Sub Add()
If (Not Me._Icon Is Nothing) Then
Me.NotifyMessage(Me.messageWindow.get_Hwnd, 0, Me.uID, Me._Icon.get_Handle)
End If
End Sub

Public Sub Add(ByVal icon As Icon)
Me.NotifyMessage(Me.messageWindow.get_Hwnd, 0, Me.uID, icon.get_Handle)
End Sub

Public Sub Add(ByVal hIcon As IntPtr)
Me.NotifyMessage(Me.messageWindow.get_Hwnd, 0, Me.uID, hIcon)
End Sub

Public Sub Add(ByVal IconRes As String)
Dim hIcon As IntPtr = NotifyIcon.LoadIcon(NotifyIcon.GetModuleHandle(Nothing), IconRes)
Me.NotifyMessage(Me.messageWindow.get_Hwnd, 0, Me.uID, hIcon)
End Sub

Protected Overrides Sub Finalize()
Try
Me.Remove
Finally
MyBase.Finalize
End Try
End Sub

<DllImport("coredll.dll")> _
Friend Shared Function GetFocus() As IntPtr
End Function

<DllImport("coredll.dll")> _
Friend Shared Function GetModuleHandle(ByVal lpModuleName As String) As IntPtr
End Function

<DllImport("coredll.dll")> _
Friend Shared Function LoadIcon(ByVal hInst As IntPtr, ByVal IconName As String) As IntPtr
End Function

Public Sub Modify(ByVal hIcon As IntPtr)
Me.NotifyMessage(Me.messageWindow.get_Hwnd, 1, Me.uID, hIcon)
End Sub

Private Sub NotifyMessage(ByVal hwnd As IntPtr, ByVal dwMessage As Integer, ByVal uID As UInt32, ByVal hIcon As IntPtr)
Dim pnid As New NOTIFYICONDATA
pnid.cbSize = &H98
pnid.hIcon = hIcon
pnid.hWnd = hwnd
pnid.uCallbackMessage = &HBD1
pnid.uFlags = 3
pnid.uID = uID
Dim num As Integer = NotifyIcon.Shell_NotifyIcon(dwMessage, (pnid))
End Sub

Public Sub Remove()
Me.NotifyMessage(Me.messageWindow.get_Hwnd, 2, Me.uID, IntPtr.Zero)
End Sub

<DllImport("coredll.dll")> _
Friend Shared Function SetForegroundWindow(ByVal hWnd As IntPtr) As Integer
End Function

<DllImport("coredll.dll")> _
Friend Shared Function Shell_NotifyIcon(ByVal dwMessage As Integer, ByRef pnid As NOTIFYICONDATA) As Integer
End Function

<DllImport("coredll.dll")> _
Friend Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Integer
End Function


' Properties
Public WriteOnly Property Icon As Icon
Set(ByVal value As Icon)
Me._Icon = value
End Set
End Property


' Fields
Private _Icon As Icon
Private Click As EventHandler
Private messageWindow As MyMessageWindow
Private Const NIF_ICON As Integer = 2
Private Const NIF_MESSAGE As Integer = 1
Friend Const NIM_ADD As Integer = 0
Friend Const NIM_DELETE As Integer = 2
Friend Const NIM_MODIFY As Integer = 1
Private uID As Integer = &H1388
Friend Const WM_LBUTTONDOWN As Integer = &H201
Friend Const WM_NOTIFY_TRAY As Integer = &HBD1

' Nested Types
Friend Class MyMessageWindow
Inherits MessageWindow
' Methods
Public Sub New(ByVal notIcon As NotifyIcon)
Me.notifyIcon = notIcon
End Sub

Protected Overrides Sub WndProc(ByRef msg As Message)
If (((msg.get_Msg Is &HBD1) AndAlso (msg.get_LParam Is &H201)) AndAlso ((msg.get_WParam Is Me._uID) AndAlso (Not Me.notifyIcon.Click Is Nothing))) Then
Me.notifyIcon.Click.Invoke(Me.notifyIcon, Nothing)
End If
End Sub


' Properties
Public WriteOnly Property uID As Integer
Set(ByVal value As Integer)
Me._uID = value
End Set
End Property


' Fields
Private _uID As Integer = 0
Private notifyIcon As NotifyIcon
End Class

<StructLayout(LayoutKind.Sequential)> _
Friend Structure NOTIFYICONDATA
Friend cbSize As Integer
Friend hWnd As IntPtr
Friend uID As UInt32
Friend uFlags As UInt32
Friend uCallbackMessage As UInt32
Friend hIcon As IntPtr
End Structure
End Class



7,655

社区成员

发帖
与我相关
我的任务
社区描述
Windows Phone是微软发布的一款手机操作系统,它将微软旗下的Xbox LIVE游戏、Zune音乐与独特的视频体验整合至手机中。
社区管理员
  • Windows客户端开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧