'

 

'

Private Sub Form_Load()

Form100.Left = Screen.Width / 2 - Form100.Width / 2 '

Form100.Top = Screen.Height / 4 '

End Sub

 

'

Private Sub Form_Resize()

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

SetTray ' Tray

FlagMinimize = 1 ' , ,

FlaNachalo = 1 ' 1, Tray

Else

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

FlagMinimize = 1 ' , ,

Form100.Hide '

End If

End If

End Sub

 

' Tray

Private Sub Command4_Click()

 

If FlaNachalo = 0 Then ' Ako Tray

SetTray ' Tray

FlaNachalo = 1 ' 1, Tray

Form100.Show ' , Tray

End If

ChangeNadpisAndIcon '

 

 

End Sub

 

' Tray

Private Sub Form_Unload(Cancel As Integer)

delIcoTray

End Sub

 

 

' TRAY

'

Public FlagMinimize

Public FlaNachalo As Integer

Public lngRetVal As Long

Public Nadpis As String

'

Public Const GWL_WNDPROC = (-4)

Public Const NIF_ICON = &H2

Public Const NIF_MESSAGE = &H1

Public Const NIF_TIP = &H4

Public Const NIM_ADD = &H0

Public Const NIM_DELETE = &H2

Public Const WM_LBUTTONDBLCLK = &H203

Public Const WM_LBUTTONDUP = &H202

Public Const WM_LBUTTONDDOWN = &H201

Public Const WM_MOUSEMOVE = &H200

Public Const WM_RBUTTONDBLCLK = &H206

Public Const WM_RBUTTONDOWN = &H204

Public Const WM_RBUTTONUP = &H205

Public Const WM_USER = &H400

Public Const OPT_DELETE = 2

Public Const WM_CALLBACK_MSG = WM_USER Or &HF

'

Type SHFILEOPSTRUCT

hwnd As Long

wFunc As Long

pFrom As String

pTo As String

fFlags As Integer

fAnyOperationsAborted As Long

hNameMappings As Long

lpszProgressTitle As String

End Type

 

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

Public lngPrevWndProc As Long

Public lngWndID As Long

Public lngHwnd As Long

Public nidTray As NOTIFYICONDATA

Public strToolTip As String

 

', 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

Form100.Show

Form100.WindowState = 0

FlagMinimize = 0

'

Case WM_RBUTTONDOWN

Form100.Show

Form100.WindowState = 0

FlagMinimize = 0

End Select

End If

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

End Function

 

 

' Tray

Public Sub delIcoTray()

Shell_NotifyIconA NIM_DELETE, nidTray

End Sub

 

'

Public Sub delIcoAll()

Shell_NotifyIconA OPT_DELETE, nidTray

End Sub

 

' Tray

Public Sub SetTray()

lngHwnd = Form100.hwnd

lngWndID = App.hInstance

strToolTip = Form100.Text1.Text & Chr(0)

lngPrevWndProc = SetWindowLong(lngHwnd, GWL_WNDPROC, AddressOf WndProcMain)

nidTray.hwnd = lngHwnd

nidTray.cbSize = Len(nidTray)

nidTray.hIcon = Form100.Icon

nidTray.szTip = strToolTip

nidTray.uCallbackMessage = WM_CALLBACK_MSG

nidTray.uID = lngWndID

nidTray.uFlags = NIF_MESSAGE Or NIF_TIP Or NIF_ICON

lngRetVal = Shell_NotifyIconA(NIM_ADD, nidTray)

Form100.Hide

End Sub

 

' Tray

Public Sub ChangeNadpisAndIcon()

Form100.Icon = Form100.Image1.Picture

Nadpis = Form100.Text1.Text

delIcoAll

nidTray.szTip = Nadpis & Chr(0)

nidTray.hIcon = Form100.Icon

Shell_NotifyIconA NIM_ADD, nidTray

End Sub