Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
| Search | Today's Posts | Mark Forums Read
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 20th, 2003, 09:52 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , .
Posts: 121
Thanks: 1
Thanked 0 Times in 0 Posts
Default Windows NT service and Icon in the System Tray

Hi experts,
I am having a problem with my Windows NT service application.
The service works OK, but I have a problem to display an Icon in the system tray connected to the service. If I am running the service in the DEBUG mode the icon shows up in the system tray, but if I turn the NTService1.Debug=False and start the service from the Control Panel the icon does not show up and Shell_NotifyIcon(NIM_ADD, nid) function returns FALSE.
I am trying to run this application on Windows 2000 pro. and on Windows 2000 Server and have same result.

Help me, please to solve this problem?
         -Dmitriy
  #2 (permalink)  
Old August 26th, 2003, 07:32 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Cardiff, , United Kingdom.
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am sorry no one has replied to your question. To me it looks as if your code should work.

Unfortunately I have no experience of developing NT Service applications, however I make regular use of Shell_NotifyIcon API call to add an icon to the system tray. NIM_ADD is the correct call to add your icon to the system tray so I can not understand why it is not appearing.

You may want to check the obvious, and ensure that you are calling the same code in both debug mode and normal mode. Also check that your constants and the NOTIFYICONDATA type are declared correctly, they should be:

Code:
Const NIM_ADD = 0
Const NIM_MODIFY = 1
Const NIM_DELETE = 2

Const NIF_MESSAGE = 1
Const NIF_ICON = 2
Const NIF_TIP = 4

Const WM_MOUSEMOVE = 512

Type NOTIFYICONDATA
  cbSize As Long
  hWnd As Long
  uID As Long
  uFlags As Long
  uCallbackMessage As Long
  hIcon As Long
  szTip(0 To 63) As Byte
End Type
Then check that all the handles are being assigned correctly, maybe you are using a different handle when running in normal mode that for some reason is not valid. If your handle to the icon is incorrect, or it is not an icon (perhaps it is a bmp) then a space will be allocated in the system tray for the icon, however it will not be displayed because nothing other than an icon will show up.

Also make sure you are setting the correct cbSize for your NOTIFYICONDATA, the best way to make sure of this is to set cbSize to:

Code:
nid.cbSize = Len(nid)
uFlags should be set NIF_MESSAGE Or NIF_ICON Or NIF_TIP and uCallbackMessage should be equal to WM_MOUSEMOVE. Other than that I am afraid I have run out of ideas.

Regards
Owain Williams
  #3 (permalink)  
Old August 26th, 2003, 01:47 PM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , .
Posts: 121
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Owain,
I do not know exactly what I've done to my application (:)), but it started to work properly. So, if you will have some problems with NT service application let me know and I will be glad to send you an example of my code.
        -Thanks,
                Dmitriy:)
  #4 (permalink)  
Old August 26th, 2003, 03:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Sparks, NV, USA.
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jlick
Default

Are you using an NT Service Toolkit, or are you building the services solely in VB.

If solely in VB, where can I find documentation on how to do this?

John R Lick
JohnRLick@hotmail.com
  #5 (permalink)  
Old August 27th, 2003, 01:23 PM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , .
Posts: 121
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi,
you can try very good link:
http://www.vbcity.com/forums/faq.asp?fid=6&cat=Windows
it has good examples.
   -Dmitriy


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Notifications from Icon in System Tray bmains General .NET 0 October 3rd, 2006 09:35 PM
System Tray Icon in VB.net Application palindrome_nitin .NET Framework 1.x 0 July 25th, 2006 05:49 AM
icon on system tray aehb Visual C++ 2 May 28th, 2006 01:46 PM
system tray icon spoboyle Apache Tomcat 1 June 9th, 2004 10:29 AM
Who can help me set up a contextmenu for tray icon koolvbnet1 Pro VB.NET 2002/2003 1 May 26th, 2004 02:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.