'

 

'

Private Sub Form_Resize()

Set FormataObekt = Me ' FormataObekt

Preorazmeriavane " " ' Tray,

End Sub

 

' Tray

Private Sub Form_Unload(Cancel As Integer)

delIcoTray ' Tray

End Sub

 

' Tray

 

'

Public FormataObekt

Public FlagMinimize

Public FlaNachalo As Integer

Public lngRetVal As Long

Public Nadpis As String

'

Public Const WM_LBUTTONDDOWN = &H201

Public Const WM_RBUTTONDOWN = &H204

Public Const WM_CALLBACK_MSG = &H400 Or &HF

Public lngPrevWndProc As Long

Public lngWndID As Long

Public nidTray As NOTIFYICONDATA

 

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

 

'

Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, _

ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

 

Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, _

ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Declare Function Shell_NotifyIconA Lib "shell32.dll" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long

 

', Tray

Public Function WndProcMain(ByVal hwnd As Long, ByVal message As Long, ByVal wParam As Long, _

ByVal lParam As Long) As Long

If lngWndID = wParam Then

Select Case lParam

'

Case WM_LBUTTONDDOWN

FormataObekt.Show

FormataObekt.WindowState = 0

FlagMinimize = 0

'

Case WM_RBUTTONDOWN

FormataObekt.Show

FormataObekt.WindowState = 0

FlagMinimize = 0

End Select

End If

WndProcMain = CallWindowProc(lngPrevWndProc, hwnd, message, wParam, lParam)

End Function

 

' Tray

Public Sub delIcoTray()

Shell_NotifyIconA &H2, nidTray

End Sub

 

' Tray

Public Sub SetTray(ObektForma, ShowText)

lngHwnd = ObektForma.hwnd

lngWndID = App.hInstance

strToolTip = ShowText & Chr(0)

lngPrevWndProc = SetWindowLong(lngHwnd, -4, AddressOf WndProcMain)

nidTray.hwnd = lngHwnd

nidTray.cbSize = Len(nidTray)

nidTray.hIcon = ObektForma.Icon

nidTray.szTip = strToolTip

nidTray.uCallbackMessage = WM_CALLBACK_MSG

nidTray.uID = lngWndID

nidTray.uFlags = &H1 Or &H4 Or &H2

lngRetVal = Shell_NotifyIconA(&H0, nidTray)

ObektForma.Hide

End Sub

 

'

Public Sub Preorazmeriavane(Nadpis)

If FormataObekt.WindowState = 1 And FlaNachalo = 0 Then ' 0

SetTray FormataObekt, Nadpis ' Tray

FlagMinimize = 1 ' , ,

FlaNachalo = 1 ' 1, Tray

Else

If FormataObekt.WindowState = 1 And FlagMinimize = 0 Then ' Ako ,

FlagMinimize = 1 ' , ,

FormataObekt.Hide '

End If

End If

End Sub