AboutRavindra Expertise visual basic application programming from design to access information, sql, engineering and commercial applications. access databases, excel.
Optional:
1)a large number of people want me to do work which takes some time and effort. Pl.note that i would like to be paid for such work.
2) if you want me to spend quality time and do special work, i expect to be paid a reasonable price for my time.
3) if you are pleased with my reply you could consider a donation of 1$.
4) you can visit my website http://ravindra.coolpage.biz (under constrn)
Experience
Past/Present clients project work for a Norway company, and a Canadian company completed. Freelance Project work and Teaching
teaching vb
Expert: Ravindra Date: 1/23/2006 Subject: Minimize app to tray
Question In VB6, is there a way to minimize the app into tray instead of to the bottom bar? or alternatively by clicking a command button on the form to do that?
Thank you in advance if you have any ideas on coding in VB6 or using API or any third party plugins.
I write apps using VB6 (VS6). I want to write an application which should be running all the time (some machines are 98 and some are XP). Preferably, it can be minimized to the system tray when it is started (as an option).
Many thanks!
Answer this is for advanced programmers only. do not attempt it if you are new.
in a .bas module
'------------------------------------------------------
' VB CENTER
'
' Tutorial: Using the system tray
' 09/26/98
'
' You may distribute this file as long as all the credits
' Are given to VB Center
'
' For more tutorials and a detailed explanation of this
' tutorial, visit our page: http://vbcenter.cjb.net
'
'------------------------------------------------------
Declare Function Shell_NotifyIcon Lib "shell32.dll" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
'If you get an error message at the beginning of the program,
'use the declaration below:
'Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias " Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
'These three constants specify what you want to do
Public Const NIM_ADD = &H0
Public Const NIM_DELETE = &H2
Public Const NIM_MODIFY = &H1
Public Const NIF_ICON = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_TIP = &H4
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_MOUSEMOVE = &H200
Public Const WM_RBUTTONDBLCLK = &H206
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
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 IconData As NOTIFYICONDATA
_______
in the form
Private Sub Form_Activate()
Call Shell_NotifyIcon(NIM_ADD, IconData)
'this is an option to show icon without minimizing the form
End Sub
Private Sub Form_Resize()
'this is the option to show icon on minimizing the form
If Me.WindowState = 1 Then
'The user has minimized his window
'Call Shell_NotifyIcon(NIM_ADD, IconData)
' Add the form's icon to the tray
Me.Hide
' Hide the button at the taskbar
End If
End Sub
Private Sub Form_Load()
With IconData
.cbSize = Len(IconData)
' The length of the NOTIFYICONDATA type
.hIcon = Me.Icon
' A reference to the form's icon
.hwnd = Me.hwnd
' hWnd of the form
.szTip = "My Tooltip" & Chr(0)
' Tooltip string delimited with a null character
.uCallbackMessage = WM_MOUSEMOVE
' The icon we're placing will send messages to the MouseMove event
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
' It will have message handling and a tooltip
.uID = vbNull
' uID is not used by VB, so it's set to a Null value