Visual Basic, .NET, ASP, VBScript
 

   
   
     

Форум - Общий форум

Страница: 1 |

 

  Вопрос: Анимация иконки в Tray Добавлено: 22.07.07 12:43  

Автор вопроса:  gekko | Web-сайт: kalamfur.ru
Все наверное видели в трее анимированные иконки
dMaster'a и KAV.. А как склепать такую на VB?? (6.0)

Ответить

  Ответы Всего ответов: 11  

Номер ответа: 1
Автор ответа:
 ZagZag



ICQ: 295002202 

Вопросов: 87
Ответов: 1684
 Профиль | | #1 Добавлено: 22.07.07 13:40
Ручками. Менять иконку по таймеру или др. событию

Ответить

Номер ответа: 2
Автор ответа:
 gekko



Вопросов: 39
Ответов: 127
 Web-сайт: kalamfur.ru
 Профиль | | #2
Добавлено: 22.07.07 16:06
If (GetAsyncKeyState(vbKeyF10)) Then
cSysTray1.TrayIcon = img1.Picture
Else
End If


==========================================

Что конкретно не верно? Или использовать не cSysTray?

Ответить

Номер ответа: 3
Автор ответа:
 EUGY



Вопросов: 0
Ответов: 454
 Профиль | | #3 Добавлено: 22.07.07 18:01
Set cSysTray1.TrayIcon = img1.Picture
Вот только причем здесь анимация и GetAsyncKeyState?

Ответить

Номер ответа: 4
Автор ответа:
 mc-black



ICQ: 308-534-060 

Вопросов: 20
Ответов: 1860
 Web-сайт: mc-black.narod.ru/dzp.htm
 Профиль | | #4
Добавлено: 22.07.07 21:43
что без каких-то там готовых классов чисто на api кишка тонка? rtmf msdn win32.hlp etc.

Ответить

Номер ответа: 5
Автор ответа:
 mc-black



ICQ: 308-534-060 

Вопросов: 20
Ответов: 1860
 Web-сайт: mc-black.narod.ru/dzp.htm
 Профиль | | #5
Добавлено: 22.07.07 21:44
ещё api guide

Ответить

Номер ответа: 6
Автор ответа:
 Winand



Вопросов: 87
Ответов: 2795
 Web-сайт: winandfx.narod.ru
 Профиль | | #6
Добавлено: 23.07.07 15:50
Зачем чисто на АПИ когда есть хорошие классы
Вот этот уже публиковал тут, сделал анимацию щас.
Жаль автора класса не знаю...
Иконка сама восстанавливается при перезагрузке панели задач! представляете?)))

Копируете в блокнот, сохраняете, переименовываете в *.mim, открываете архиватором
B64Encode (WinAce Archiver www.winace.com)

Content-Type: application/octet-stream; name="Truetray.zip";
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Truetray.zip"

begin-base64 664 Truetray.zip
UEsDBBQAAAAIAIIE1jb7nKM6jQUAAHcRAAANAAAAY2xzSW5UcmF5LmNsc61X227bOBB9D5B/GPih
cQA3SF8XKBa+KFlhfYMlJ+iTQUm0zS1NCiRl1/36DklZFzdeJ0CFILbIM4dzhsPh+CVYROFsCl8e
HmE47kfR7c0geA6ntzcAk4IbttQUvsLnLwB3sSqoHZ9TpZk2JOF26hFnptLUgw4zIoYMmMiY2Azo
luyZVCV2n0ylqDCRLFRKK8hvmEkcxYoITVLDpJjIjEK9Zl/g9Cz5j6bm9iaYjm5v+sYolhSGwstg
NSU762An5ToUyHLsnAGeuUwIt7AoJ6nFPhGu6RlqqCg5icUQnE/PFc1oygl+hNkFiuBHLjVtzN59
/iMPEkWGKANyDUNOtAaMUMHpX1Bpvr25vZnlNniAXnCWMmOH5ortCTq3W21fRfYPyzIqoK9hLMUG
7kbFbneEA+6fPEBhPV9LBSnhHBKSftdNe8EyazidxeHTt3A4m476cb8JSF6YZhg+ixpIySkRcBdq
MFsKLEW/9uX8kZq/m4baS0KzyChMJOd3kaAGCPZUGBSLvk3knnbv35pZ5t1BYYx0wkJh6IaqN4Ej
eRDXoaOED/Ht+5tI3IkY9WyJyDi122HsW2jlGWlDWJHNlcypMkd4psYjuvenyNuMB/D/vfFXH+EH
93aaDkRW0dilz5nHFbOgB89TLnDfWKFi9uucoE3EkHBuU4qtj3aqvbIXLSUHw3KbIE6zPmpDd2Aw
9dzuvq07ZjmqLne2rRunKtX6J769R69ndPCatS22JkR6//kJsNAUnA+3RH1Mdj/LGgls5Ln0B8RA
dNoGwKxwuhKKYaLuIKF/aMQ0rAvhalslKyoSQH63fy0JI5oUm4e+1uhGfa6qstWERlvK+QpLZCkB
pu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YgQaz6f3d53KY3ltOAzOZApgXVXeQJ4/B5BeIerPEKtITaAs6+92f0KYoXR0PiCC
NvAHUEsBAhQAFAAAAAgAggTWNvucozqNBQAAdxEAAA0AAAAAAAAAAAAgCAAAAAAAAGNsc0luVHJh
eS5jbHNQSwECFAAUAAAACAC9ffc2JIj/H5EFAAAmDwAACQAAAAAAAAAAACAIAAC4BQAARm9ybTEu
ZnJtUEsBAhQAFAAAAAgAvX33NofZwPhsAQAAqgwAAAkAAAAAAAAAAAAgCAAAcAsAAEZvcm0xLmZy
eFBLAQIUABQAAAAIAIIE1jZBTjOU8QUAAA8VAAANAAAAAAAAAAAAIAgAAAMNAABtb2RJblRyYXku
YmFzUEsBAhQAFAAAAAgAvX33NlfsM4S2AQAAzwIAAAwAAAAAAAAAAAAgCAAAHxMAAFByb2plY3Qx
LnZicFBLAQIUABQAAAAIAMJ99zbgaXB7cwAAAJkAAAAMAAAAAAAAAAAAIAgAAP8UAABQcm9qZWN0
MS52YndQSwUGAAAAAAYABgBYAQAAnBUAAAAA

end
5898 bytes

Ответить

Номер ответа: 7
Автор ответа:
 Winand



Вопросов: 87
Ответов: 2795
 Web-сайт: winandfx.narod.ru
 Профиль | | #7
Добавлено: 23.07.07 15:54
там одного модуля нет - ругается, но он и не нужен

Ответить

Номер ответа: 8
Автор ответа:
 Fever



Вопросов: 60
Ответов: 808
 Профиль | | #8 Добавлено: 23.07.07 19:27
frmSysTray.frm

VERSION 5.00
Begin VB.Form frmSysTray
   Caption         =   "Sys Tray Interface"
   ClientHeight    =   1920
   ClientLeft      =   5610
   ClientTop       =   3360
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   1920
   ScaleWidth      =   4680
   Begin VB.Menu mnuPopup
      Caption         =   "&Popup"
      Begin VB.Menu mnuSysTray
         Caption         =   ""
         Index           =   0
      End
   End
End
Attribute VB_Name = "frmSysTray"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

' 03/03/2003
' * Added Unicode support
' * Added support for new tray version (ME,2000 or above required)
' * Added support for balloon tips (ME,2000 or above required)

' frmSysTray.
' Steve McMahon
' Original version based on code supplied from Ben Baird:

'Author:
'        Ben Baird <psyborg@cyberhighway.com>
'        Copyright (c) 1997, Ben Baird
'
'Purpose:
'        ;Demonstrates setting an icon in the taskbar's
'        system tray without the overhead of subclassing
'        to receive events.

Private Declare Function Shell_NotifyIconA Lib "shell32.dll" _
   ;(ByVal dwMessage As Long, lpData As NOTIFYICONDATAA) As Long
   
Private Declare Function Shell_NotifyIconW Lib "shell32.dll" _
   ;(ByVal dwMessage As Long, lpData As NOTIFYICONDATAW) As Long


Private Const NIF_ICON = &H2
Private Const NIF_MESSAGE = &H1
Private Const NIF_TIP = &H4
Private Const NIF_STATE = &H8
Private Const NIF_INFO = &H10

Private Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2
Private Const NIM_SETFOCUS = &H3
Private Const NIM_SETVERSION = &H4

Private Const NOTIFYICON_VERSION = 3

Private Type NOTIFYICONDATAA
   cbSize As Long             ' 4
   hwnd As Long               ' 8
   uID As Long                ' 12
   uFlags As Long             ' 16
   uCallbackMessage As Long   ' 20
   hIcon As Long              ' 24
   szTip As String * 128      ' 152
   dwState As Long            ' 156
   dwStateMask As Long        ' 160
   szInfo As String * 256     ' 416
   uTimeOutOrVersion As Long  ' 420
   szInfoTitle As String * 64 ' 484
   dwInfoFlags As Long        ' 488
   guidItem As Long           ' 492
End Type
Private Type NOTIFYICONDATAW
   cbSize As Long             ' 4
   hwnd As Long               ' 8
   uID As Long                ' 12
   uFlags As Long             ' 16
   uCallbackMessage As Long   ' 20
   hIcon As Long              ' 24
   szTip(0 To 255) As Byte    ' 280
   dwState As Long            ' 284
   dwStateMask As Long        ' 288
   szInfo(0 To 511) As Byte   ' 800
   uTimeOutOrVersion As Long  ' 804
   szInfoTitle(0 To 127) As Byte ' 932
   dwInfoFlags As Long        ' 936
   guidItem As Long           ' 940
End Type


Private nfIconDataA As NOTIFYICONDATAA
Private nfIconDataW As NOTIFYICONDATAW

Private Const NOTIFYICONDATAA_V1_SIZE_A = 88
Private Const NOTIFYICONDATAA_V1_SIZE_U = 152
Private Const NOTIFYICONDATAA_V2_SIZE_A = 488
Private Const NOTIFYICONDATAA_V2_SIZE_U = 936

Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long

Private Const WM_MOUSEMOVE = &H200
Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const WM_RBUTTONDBLCLK = &H206
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_RBUTTONUP = &H205

Private Const WM_USER = &H400

Private Const NIN_SELECT = WM_USER
Private Const NINF_KEY = &H1
Private Const NIN_KEYSELECT = (NIN_SELECT Or NINF_KEY)
Private Const NIN_BALLOONSHOW = (WM_USER + 2)
Private Const NIN_BALLOONHIDE = (WM_USER + 3)
Private Const NIN_BALLOONTIMEOUT = (WM_USER + 4)
Private Const NIN_BALLOONUSERCLICK = (WM_USER + 5)

' Version detection:
Private Declare Function GetVersion Lib "kernel32" () As Long

Public Event SysTrayMouseDown(ByVal eButton As MouseButtonConstants)
Public Event SysTrayMouseUp(ByVal eButton As MouseButtonConstants)
Public Event SysTrayMouseMove()
Public Event SysTrayDoubleClick(ByVal eButton As MouseButtonConstants)
Public Event MenuClick(ByVal lIndex As Long, ByVal sKey As String)
Public Event BalloonShow()
Public Event BalloonHide()
Public Event BalloonTimeOut()
Public Event BalloonClicked()

Public Enum EBalloonIconTypes
   NIIF_NONE = 0
   NIIF_INFO = 1
   NIIF_WARNING = 2
   NIIF_ERROR = 3
   NIIF_NOSOUND = &H10
End Enum

Private m_bAddedMenuItem As Boolean
Private m_iDefaultIndex As Long

Private m_bUseUnicode As Boolean
Private m_bSupportsNewVersion As Boolean

Public Sub ShowBalloonTip( _
      ByVal sMessage As String, _
      Optional ByVal sTitle As String, _
      Optional ByVal eIcon As EBalloonIconTypes, _
      Optional ByVal lTimeOutMs = 30000 _
   ;)
Dim lR As Long
   If (m_bSupportsNewVersion) Then
      If (m_bUseUnicode) Then
         stringToArray sMessage, nfIconDataW.szInfo, 512
         stringToArray sTitle, nfIconDataW.szInfoTitle, 128
         nfIconDataW.uTimeOutOrVersion = lTimeOutMs
         nfIconDataW.dwInfoFlags = eIcon
         nfIconDataW.uFlags = NIF_INFO
         lR = Shell_NotifyIconW(NIM_MODIFY, nfIconDataW)
      Else
         nfIconDataA.szInfo = sMessage
         nfIconDataA.szInfoTitle = sTitle
         nfIconDataA.uTimeOutOrVersion = lTimeOutMs
         nfIconDataA.dwInfoFlags = eIcon
         nfIconDataA.uFlags = NIF_INFO
         lR = Shell_NotifyIconA(NIM_MODIFY, nfIconDataA)
      End If
   Else
      ' can't do it, fail silently.
   End If
End Sub

Public Property Get ToolTip() As String
Dim sTip As String
Dim iPos As Long
    sTip = nfIconDataA.szTip
    iPos = InStr(sTip, Chr$(0))
    If (iPos <> 0) Then
        sTip = Left$(sTip, iPos - 1)
    End If
    ToolTip = sTip
End Property
Public Property Let ToolTip(ByVal sTip As String)
   If (m_bUseUnicode) Then
      stringToArray sTip, nfIconDataW.szTip, unicodeSize(IIf(m_bSupportsNewVersion, 128, 64))
      nfIconDataW.uFlags = NIF_TIP
      Shell_NotifyIconW NIM_MODIFY, nfIconDataW
   Else
      If (sTip & Chr$(0) <> nfIconDataA.szTip) Then
         nfIconDataA.szTip = sTip & Chr$(0)
         nfIconDataA.uFlags = NIF_TIP
         Shell_NotifyIconA NIM_MODIFY, nfIconDataA
      End If
   End If
End Property

Public Property Get IconHandle() As Long
    IconHandle = nfIconDataA.hIcon
End Property
Public Property Let IconHandle(ByVal hIcon As Long)
   If (m_bUseUnicode) Then
      If (hIcon <> nfIconDataW.hIcon) Then
         nfIconDataW.hIcon = hIcon
         nfIconDataW.uFlags = NIF_ICON
         Shell_NotifyIconW NIM_MODIFY, nfIconDataW
      End If
   Else
      If (hIcon <> nfIconDataA.hIcon) Then
         nfIconDataA.hIcon = hIcon
         nfIconDataA.uFlags = NIF_ICON
         Shell_NotifyIconA NIM_MODIFY, nfIconDataA
      End If
   End If
End Property

Public Function AddMenuItem(ByVal sCaption As String, Optional ByVal sKey As String = "", Optional ByVal bDefault As Boolean = False) As Long
Dim iIndex As Long
    If Not (m_bAddedMenuItem) Then
        iIndex = 0
        m_bAddedMenuItem = True
    Else
        iIndex = mnuSysTray.UBound + 1
        Load mnuSysTray(iIndex)
    End If
    mnuSysTray(iIndex).Visible = True
    mnuSysTray(iIndex).Tag = sKey
    mnuSysTray(iIndex).Caption = sCaption
    If (bDefault) Then
        m_iDefaultIndex = iIndex
    End If
    AddMenuItem = iIndex
End Function

Private Function ValidIndex(ByVal lIndex As Long) As Boolean
    ValidIndex = (lIndex >= mnuSysTray.LBound And lIndex <= mnuSysTray.UBound)
End Function

Public Sub EnableMenuItem(ByVal lIndex As Long, ByVal bState As Boolean)
    If (ValidIndex(lIndex)) Then
        mnuSysTray(lIndex).Enabled = bState
    End If
End Sub

Public Function RemoveMenuItem(ByVal iIndex As Long) As Long
Dim i As Long
   If ValidIndex(iIndex) Then
      If (iIndex = 0) Then
         mnuSysTray(0).Caption = ""
      Else
         ' remove the item:
         For i = iIndex + 1 To mnuSysTray.UBound
            mnuSysTray(iIndex - 1).Caption = mnuSysTray(iIndex).Caption
            mnuSysTray(iIndex - 1).Tag = mnuSysTray(iIndex).Tag
         Next i
         Unload mnuSysTray(mnuSysTray.UBound)
      End If
   End If
End Function

Public Property Get DefaultMenuIndex() As Long
   ;DefaultMenuIndex = m_iDefaultIndex
End Property

Public Property Let DefaultMenuIndex(ByVal lIndex As Long)
   If (ValidIndex(lIndex)) Then
      m_iDefaultIndex = lIndex
   Else
      m_iDefaultIndex = 0
   End If
End Property

Public Function ShowMenu()
   SetForegroundWindow Me.hwnd
   If (m_iDefaultIndex > -1) Then
      Me.PopupMenu mnuPopup, 0, , , mnuSysTray(m_iDefaultIndex)
   Else
      Me.PopupMenu mnuPopup, 0
   End If
End Function

Private Sub Form_Load()
   ' Get version:
   Dim lMajor As Long
   Dim lMinor As Long
   Dim bIsNt As Long
   GetWindowsVersion lMajor, lMinor, , , bIsNt

   If (bIsNt) Then
      m_bUseUnicode = True
      If (lMajor >= 5) Then
         ' 2000 or XP
         m_bSupportsNewVersion = True
      End If
   ElseIf (lMajor = 4) And (lMinor = 90) Then
      ' Windows ME
      m_bSupportsNewVersion = True
   End If
   
   
   'Add the icon to the system tray...
   Dim lR As Long
   
   If (m_bUseUnicode) Then
      With nfIconDataW
         .hwnd = Me.hwnd
         .uID = Me.Icon
         .uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
         .uCallbackMessage = WM_MOUSEMOVE
         .hIcon = Me.Icon.Handle
         stringToArray App.FileDescription, .szTip, unicodeSize(IIf(m_bSupportsNewVersion, 128, 64))
         If (m_bSupportsNewVersion) Then
            .uTimeOutOrVersion = NOTIFYICON_VERSION
         End If
         .cbSize = nfStructureSize
      End With
      lR = Shell_NotifyIconW(NIM_ADD, nfIconDataW)
      If (m_bSupportsNewVersion) Then
         Shell_NotifyIconW NIM_SETVERSION, nfIconDataW
      End If
   Else
      With nfIconDataA
         .hwnd = Me.hwnd
         .uID = Me.Icon
         .uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
         .uCallbackMessage = WM_MOUSEMOVE
         .hIcon = Me.Icon.Handle
         .szTip = App.FileDescription & Chr$(0)
         If (m_bSupportsNewVersion) Then
            .uTimeOutOrVersion = NOTIFYICON_VERSION
         End If
         .cbSize = nfStructureSize
      End With
      lR = Shell_NotifyIconA(NIM_ADD, nfIconDataA)
      If (m_bSupportsNewVersion) Then
         lR = Shell_NotifyIconA(NIM_SETVERSION, nfIconDataA)
      End If
   End If
   
End Sub

Private Sub stringToArray( _
      ByVal sString As String, _
      bArray() As Byte, _
      ByVal lMaxSize As Long _
   ;)
Dim b() As Byte
Dim i As Long
Dim j As Long
   If Len(sString) > 0 Then
      b = sString
      For i = LBound(b) To UBound(b)
         bArray(i) = b(i)
         If (i = (lMaxSize - 2)) Then
            Exit For
         End If
      Next i
      For j = i To lMaxSize - 1
         bArray(j) = 0
      Next j
   End If
End Sub
Private Function unicodeSize(ByVal lSize As Long) As Long
   If (m_bUseUnicode) Then
      unicodeSize = lSize * 2
   Else
      unicodeSize = lSize
   End If
End Function

Private Property Get nfStructureSize() As Long
   If (m_bSupportsNewVersion) Then
      If (m_bUseUnicode) Then
         nfStructureSize = NOTIFYICONDATAA_V2_SIZE_U
      Else
         nfStructureSize = NOTIFYICONDATAA_V2_SIZE_A
      End If
   Else
      If (m_bUseUnicode) Then
         nfStructureSize = NOTIFYICONDATAA_V1_SIZE_U
      Else
         nfStructureSize = NOTIFYICONDATAA_V1_SIZE_A
      End If
   End If
End Property

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim lX As Long
   ' VB manipulates the x value according to scale mode:
   ' we must remove this before we can interpret the
   ' message windows was trying to send to us:
   lX = ScaleX(x, Me.ScaleMode, vbPixels)
   Select Case lX
   Case WM_MOUSEMOVE
      RaiseEvent SysTrayMouseMove
   Case WM_LBUTTONUP
      RaiseEvent SysTrayMouseDown(vbLeftButton)
   Case WM_LBUTTONUP
      RaiseEvent SysTrayMouseUp(vbLeftButton)
   Case WM_LBUTTONDBLCLK
      RaiseEvent SysTrayDoubleClick(vbLeftButton)
   Case WM_RBUTTONDOWN
      RaiseEvent SysTrayMouseDown(vbRightButton)
   Case WM_RBUTTONUP
      RaiseEvent SysTrayMouseUp(vbRightButton)
   Case WM_RBUTTONDBLCLK
      RaiseEvent SysTrayDoubleClick(vbRightButton)
   Case NIN_BALLOONSHOW
      RaiseEvent BalloonShow
   Case NIN_BALLOONHIDE
      RaiseEvent BalloonHide
   Case NIN_BALLOONTIMEOUT
      RaiseEvent BalloonTimeOut
   Case NIN_BALLOONUSERCLICK
      RaiseEvent BalloonClicked
   End Select

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   If (m_bUseUnicode) Then
      Shell_NotifyIconW NIM_DELETE, nfIconDataW
   Else
      Shell_NotifyIconA NIM_DELETE, nfIconDataA
   End If
End Sub

Private Sub mnuSysTray_Click(Index As Integer)
   RaiseEvent MenuClick(Index, mnuSysTray(Index).Tag)
End Sub

Private Sub GetWindowsVersion( _
      Optional ByRef lMajor = 0, _
      Optional ByRef lMinor = 0, _
      Optional ByRef lRevision = 0, _
      Optional ByRef lBuildNumber = 0, _
      Optional ByRef bIsNt = False _
   ;)
Dim lR As Long
   lR = GetVersion()
   lBuildNumber = (lR And &H7F000000) \ &H1000000
   If (lR And &H80000000) Then lBuildNumber = lBuildNumber Or &H80
   lRevision = (lR And &HFF0000) \ &H10000
   lMinor = (lR And &HFF00&;) \ &H100
   lMajor = (lR And &HFF)
   bIsNt = ((lR And &H80000000) = 0)
End Sub




frmSysTrayDemo

VERSION 5.00
Begin VB.Form frmDemo
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "SysTray Sample Application"
   ClientHeight    =   4125
   ClientLeft      =   4920
   ClientTop       =   1785
   ClientWidth     =   5790
   Icon            =   "fDemo.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4125
   ScaleWidth      =   5790
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton cmdShowBalloon
      Caption         =   "Show In&foTip"
      Height          =   495
      Left            =   180
      TabIndex        =   6
      Top             =   3420
      Width           =   1395
   End
   Begin VB.OptionButton optIcon
      Caption         =   "&Stimpy"
      Height          =   375
      Index           =   2
      Left            =   660
      TabIndex        =   5
      Top             =   2760
      Width           =   1335
   End
   Begin VB.OptionButton optIcon
      Caption         =   "&Tooth Beaver"
      Height          =   375
      Index           =   1
      Left            =   660
      TabIndex        =   4
      Top             =   2220
      Width           =   1335
   End
   Begin VB.OptionButton optIcon
      Caption         =   "&Bob"
      Height          =   375
      Index           =   0
      Left            =   660
      TabIndex        =   3
      Top             =   1620
      Value           =   -1  'True
      Width           =   1335
   End
   Begin VB.CheckBox chkSysTray
      Caption         =   "&Show in Systray"
      Height          =   255
      Left            =   120
      TabIndex        =   0
      Top             =   1200
      Value           =   1  'Checked
      Width           =   4455
   End
   Begin VB.Image imgIcon
      Height          =   480
      Index           =   2
      Left            =   120
      Picture         =   "fDemo.frx":08CA
      Top             =   2700
      Width           =   480
   End
   Begin VB.Image imgIcon
      Height          =   480
      Index           =   1
      Left            =   120
      Picture         =   "fDemo.frx":148C
      Top             =   2100
      Width           =   480
   End
   Begin VB.Image imgIcon
      Height          =   480
      Index           =   0
      Left            =   120
      Picture         =   "fDemo.frx":1D56
      Top             =   1560
      Width           =   480
   End
   Begin VB.Image imgLogo
      Height          =   660
      Left            =   120
      Picture         =   "fDemo.frx":2620
      Top             =   120
      Width           =   2535
   End
   Begin VB.Label lblDetail
      BackStyle       =   0  'Transparent
      Caption         =   "VB Source Code and Tips at http://vbaccelerator.com/"
      BeginProperty Font
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   495
      Left            =   2760
      TabIndex        =   1
      Top             =   240
      Width           =   2835
   End
   Begin VB.Label lblBlack
      BackColor       =   &H00000000&
      BorderStyle     =   1  'Fixed Single
      Height          =   795
      Left            =   60
      TabIndex        =   2
      Top             =   60
      Width           =   5655
   End
End
Attribute VB_Name = "frmDemo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private WithEvents m_frmSysTray As frmSysTray
Attribute m_frmSysTray.VB_VarHelpID = -1

Private Sub SetIcon()
    Select Case True
    Case optIcon(0).Value
        m_frmSysTray.IconHandle = imgIcon(0).Picture.Handle
    Case optIcon(1).Value
        m_frmSysTray.IconHandle = imgIcon(1).Picture.Handle
    Case optIcon(2).Value
        m_frmSysTray.IconHandle = imgIcon(2).Picture.Handle
    End Select
End Sub

Private Sub chkSysTray_Click()
    If (chkSysTray.Value = Checked) Then
        Set m_frmSysTray = New frmSysTray
        With m_frmSysTray
            .AddMenuItem "&Open SysTray Sample", "open", True
            .AddMenuItem "-"
            .AddMenuItem "&vbAccelerator on the Web", "vbAccelerator"
            .AddMenuItem "&About...", "About"
            .AddMenuItem "-"
            .AddMenuItem "&Close", "close"
            .ToolTip = "SysTray Sample!"
        End With
        SetIcon
    Else
        Unload m_frmSysTray
        Set m_frmSysTray = Nothing
    End If
End Sub

Private Sub cmdShowBalloon_Click()
   m_frmSysTray.ShowBalloonTip _
      "Hello from vbAccelerator.com.  This SysTray form allows Unicode text and balloon tips.", _
      "vbAccelerator SysTray Sample", _
      NIIF_INFO
End Sub

Private Sub Form_Load()
    chkSysTray_Click
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Unload m_frmSysTray
    Set m_frmSysTray = Nothing
End Sub

Private Sub m_frmSysTray_MenuClick(ByVal lIndex As Long, ByVal sKey As String)
   Select Case sKey
   Case "open"
      Me.Show
      Me.ZOrder
   Case "close"
      Unload Me
   Case Else
      MsgBox "Clicked item with key " & sKey, vbInformation
   End Select
    
End Sub

Private Sub m_frmSysTray_SysTrayDoubleClick(ByVal eButton As MouseButtonConstants)
    Me.Show
    Me.ZOrder
End Sub

Private Sub m_frmSysTray_SysTrayMouseDown(ByVal eButton As MouseButtonConstants)
    If (eButton = vbRightButton) Then
        m_frmSysTray.ShowMenu
    End If
End Sub

Private Sub optIcon_Click(Index As Integer)
    SetIcon
End Sub

Ответить

Номер ответа: 9
Автор ответа:
 Millenium



ICQ: 629966 

Вопросов: 118
Ответов: 903
 Web-сайт: www.aliyev.us
 Профиль | | #9
Добавлено: 24.07.07 10:06
Зачем флудить на форуме!!! Ну тупоая молодеж пошла!!! Ты в раздел примеры смотрел??? НАВЕРНЯКА (ДАЖЕ ТОЧНО) НЕТ!!!

Лишная загрузка сайта! А на фиг раздел примеры?

Ответить

Номер ответа: 10
Автор ответа:
 Fever



Вопросов: 60
Ответов: 808
 Профиль | | #10 Добавлено: 24.07.07 10:48
миллениум, ты чего? такого кода, как я дал все равно ни у кого нет, кроме алекса, и то он у него появился вчера =)

Ответить

Номер ответа: 11
Автор ответа:
 VβÐUηìt



Вопросов: 246
Ответов: 3333
 Web-сайт: смекаешь.рф
 Профиль | | #11
Добавлено: 30.07.07 09:23
Извинаюсь, но код - какашка. У меня трей раздуло кадрами иконки. УЖОЗ!

Ответить

Страница: 1 |

Поиск по форуму



© Copyright 2002-2011 VBNet.RU | Пишите нам