HOW TO MINIMIZED AN APP TO SYSTEM TRAY IN VB? by dhruvonet
TrayIt_system_tray.jpg
THIS IS FOR ADVANCED PROGRAMMERS ONLY. DO NOT ATTEMPT IT IF YOU ARE NEW.

This example will "minimize" your program to the system tray when you click on a button, and restore it when you click the system tray icon.
 
Remove these adsRemove these ads by Signing Up

Step 1: Add Necessary Controls

pic_3.bmp
Pic_4.bmp
For this example you'll need:
1 Form - Form1
1 button - Command1

Add a Module to your project, and ad this code:

' Create an Icon in System Tray Needs
'------------------------------------------------------
'
' Tutorial: Using the system tray
' 09/26/98
'
' Distributed by : Dhrubajyoti Nath e-mail : dhruvonet@yahoo.co.in
'------------------------------------------------------

Public 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
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const WM_MOUSEMOVE = &H200
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_LBUTTONDBLCLK = &H203 'Double-click
Public Const WM_LBUTTONDOWN = &H201 'Button down
Public Const WM_LBUTTONUP = &H202 'Button up
Public Const WM_RBUTTONDBLCLK = &H206 'Double-click
Public Const WM_RBUTTONDOWN = &H204 'Button down
Public Const WM_RBUTTONUP = &H205 'Button up

Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Programmiere Chao says: Oct 23, 2011. 11:50 AM
if code is to be used with MDI forms please consider replacing

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)

with

Private Sub MDIForm_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)

normal form events are
Form_event()
but mdi forms are
MDIForm_event()
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!