我想做一个类似flashget软件的软件,在最小化时隐藏,在任务栏上显示一个图标,必要时可以通过任务栏上的图标调出窗口,不知道该怎么实现?谢谢!!!

解决方案 »

  1.   

    窗体加一个 picture1, 放一图片
    窗体代码: Private Type NOTIFYICONDATA
     cbSize As Long
     hWnd As Long
     uId As Long
     uFlags As Long
     ucallbackMessage As Long
     hIcon As Long
     szTip As String * 64
     End Type
     
     Private Const NIM_ADD = &H0
      Private Const NIM_delete = &H2
     Private Const WM_mousemove = &H200
     Private Const NIF_MESSAGE = &H1
      Private Const NIF_ICON = &H2
      Private Const NIF_TIP = &H4
      
    Private t As NOTIFYICONDATA
    Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" _
    (ByVal dw_Message As Long, pnid As NOTIFYICONDATA) As Boolean
    Private Sub Form_Resize()
      If Me.WindowState = vbMinimized Then
        t.cbSize = Len(t)
        t.hWnd = Picture1.hWnd
        t.uId = 1&
        t.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
           t.ucallbackMessage = WM_mousemove
           t.hIcon = Picture1.Picture
           t.szTip = "最大化窗口"
           Shell_NotifyIcon NIM_ADD, t
           Me.Hide
        End If
           
    End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
     If Me.WindowState <> vbMinimized Then
     Exit Sub
     End If
      
      If ((Button And vbLeftButton) > 0) Then
       t.cbSize = Len(t)
       t.hWnd = Picture1.hWnd
       t.uFlags = NIF_ICON
       t.uId = 1&
       Shell_NotifyIcon NIM_delete, t
       Me.WindowState = vbNormal
       Me.Show
       End If
       
     
    End Sub
      

  2.   

    注意 窗体的 borderstyle为sizable
      

  3.   

    http://www.vbaccelerator.com/home/VB/Code/Libraries/Shell_Projects/SysTray_-_The_Easy_Way/article.asp
      

  4.   

    注意picture1 内放的是图标, 即*.ico 文件