Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Systray IP address tool

Status
Not open for further replies.

donjohnson

Programmer
Jun 23, 2004
53
Hello!
I am somewhat new to VB, and would like to write a small app that would run in the systray, and either clicking or hovering would display for the user the current machine's name and IP address. We have just hidden the VNC icon from the users, and need an alternative to be able to support them remotely.

Can someone help me, as I have no idea where to start to create a systray app?

Thanks in advance!

Don Johnson
 
I know there's at least one thread in this forum that has info about minimizing a program to the systray. Try searching the forum.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
I can't take credit for this. I believe it came from the KDP Team (KDPTeam@hotmail.com). You'll need a form, a picture box, three image controls (as an array) inside the picture box control (using it as a container). I hope this helps.

Ron

Option Explicit
Public MSG As String

Private 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

Private Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4

Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_RBUTTONUP = &H205

Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Dim TrayI As NOTIFYICONDATA
Private Sub Form_Load()
TrayI.cbSize = Len(TrayI)
TrayI.hWnd = picHook.hWnd
TrayI.uId = 1&
TrayI.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
TrayI.ucallbackMessage = WM_LBUTTONDOWN
TrayI.hIcon = imgIcon(2).Picture
TrayI.szTip = "Time Card Utility" & Chr$(0)
Shell_NotifyIcon NIM_ADD, TrayI

Me.Hide
End Sub
Private Sub Form_Unload(Cancel As Integer)
TrayI.cbSize = Len(TrayI)
TrayI.hWnd = picHook.hWnd
TrayI.uId = 1&
Shell_NotifyIcon NIM_DELETE, TrayI
End
End Sub
Private Sub mnuPop_Click(Index As Integer)
Select Case Index
Case 0
MsgBox "Some Code", vbInformation + vbOKOnly
Case 1
Me.Show
Me.WindowState = vbNormal
Case 2
Unload Me
End Select
End Sub
Private Sub pichook_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
MSG = X / Screen.TwipsPerPixelX
If MSG = WM_LBUTTONDBLCLK Then
mnuPop_Click 0
ElseIf MSG = WM_RBUTTONUP Then
Me.PopupMenu mnupopup
End If
End Sub
Private Sub Timer1_Timer()
Static Tek As Integer
Me.Icon = imgIcon(Tek).Picture
TrayI.hIcon = imgIcon(Tek).Picture
Tek = Tek + 1
If Tek = 3 Then Tek = 0
Shell_NotifyIcon NIM_MODIFY, TrayI
End Sub




 
RonRepp
Instead of copy & pasting stuff from mentalis.org (formerly AllApi) and risking copyright infringement, you can just point to it instead:

notifyicon api

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top