Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

VB - Load an application to the System Tray

Thread Tools
 
Search this Thread
 
Old 30 September 2003, 10:37 AM
  #1  
ChrisB
Moderator
Thread Starter
 
ChrisB's Avatar
 
Join Date: Dec 1998
Location: Staffs
Posts: 23,573
Likes: 0
Received 0 Likes on 0 Posts
Post

I'd like to load an application straight into the SysTray.

Now, the said application is happy to live in the tray but there's no option to have it load straight into it. The user has to manually click 'X' to send it to the tray. As ever, the less the user has to do and get confused about, the better!

Ideally I'd like to do it from a VB App. Suggestions? I've found 3rd party pre-built utilities to do this but it would be nice to do it from code (API or ActiveX) without having to start installing other applications.

Chris.
Old 30 September 2003, 11:00 AM
  #2  
milo
Scooby Regular
 
milo's Avatar
 
Join Date: Nov 2001
Posts: 2,043
Likes: 0
Received 0 Likes on 0 Posts
Post

it's been years since ive done vb... but even if there isn't a way to load it straight in (im sure there is), why don't you just call the same event which is called when the user clicks the "x" in Form_Load()?

better still, why not put the code to send it to the systray in Form_Load itself?
Old 30 September 2003, 11:05 AM
  #3  
ChrisB
Moderator
Thread Starter
 
ChrisB's Avatar
 
Join Date: Dec 1998
Location: Staffs
Posts: 23,573
Likes: 0
Received 0 Likes on 0 Posts
Post

Oops, I need to clarify...

I have a 3rd party application - a VPN client.

I can load it from the command line or a shortcut and enable a VPN connection within in it using a command line parameter.

What I want to do is to then 'close' the VPN Client into the SysTray. At present, the user has to click the X to do this and for the less savvy users, it's just going to confuse them.

Chris.
Old 30 September 2003, 11:14 AM
  #4  
IWatkins
Scooby Regular
 
IWatkins's Avatar
 
Join Date: Mar 2000
Location: Gloucestershire, home of the lawnmower.
Posts: 4,531
Likes: 0
Received 0 Likes on 0 Posts
Post

Chris,

I'm guessing here, but maybe the action of clicking the X actually minimises the application. If so, can you not just run the application but start it in minimised state rather than normal. Play with the "Run" option for the shortcut.

Cheers

Ian
Old 30 September 2003, 11:31 AM
  #5  
ChrisB
Moderator
Thread Starter
 
ChrisB's Avatar
 
Join Date: Dec 1998
Location: Staffs
Posts: 23,573
Likes: 0
Received 0 Likes on 0 Posts
Post

Tried that by calling a Shortcut set to Minimize and no joy. When you hit the X the client is removed from the Taskbar and lives purely in the SysTray.

We did discover that if you call a .exe straight from a batch file, the batch file stops running until that exe is closed. Call a shortcut (.lnk) and the batch file carries on running.
Old 30 September 2003, 04:38 PM
  #6  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

you could do it with an autoit script and compile it to an exe.

David
Old 30 September 2003, 06:25 PM
  #7  
TopBanana
Scooby Regular
 
TopBanana's Avatar
 
Join Date: Jan 2001
Posts: 9,781
Likes: 0
Received 0 Likes on 0 Posts
Post

VB6, now that takes me back

You need to find the handle to the window you want to close (use FindWindow in user32), then send it a close message (use SendMessage).

These declares should help...

Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Old 30 September 2003, 06:30 PM
  #8  
TopBanana
Scooby Regular
 
TopBanana's Avatar
 
Join Date: Jan 2001
Posts: 9,781
Likes: 0
Received 0 Likes on 0 Posts
Post

Do something like:

SendMessage(FindWindow("VPNWINDOWCLASS",vbNull),WM _CLOSE,0)

You can find the value of "VPNWINDOWCLASS" using Microsoft Spy++ which comes with Visual Studio 6 or similar.
Old 30 September 2003, 09:18 PM
  #9  
ChrisB
Moderator
Thread Starter
 
ChrisB's Avatar
 
Join Date: Dec 1998
Location: Staffs
Posts: 23,573
Likes: 0
Received 0 Likes on 0 Posts
Thumbs up

Excellent stuff James! Many thanks

Chris.
Old 30 September 2003, 09:57 PM
  #10  
ChrisB
Moderator
Thread Starter
 
ChrisB's Avatar
 
Join Date: Dec 1998
Location: Staffs
Posts: 23,573
Likes: 0
Received 0 Likes on 0 Posts
Post

James,

Would "Afx:400000:0:0:0:60865" be a valid class name? I've found the process in Spy++ and that's in the "Class Name" box...
Old 30 September 2003, 10:18 PM
  #11  
ChrisB
Moderator
Thread Starter
 
ChrisB's Avatar
 
Join Date: Dec 1998
Location: Staffs
Posts: 23,573
Likes: 0
Received 0 Likes on 0 Posts
Post

Wooooo! Cheers James - got it working
Old 30 September 2003, 11:23 PM
  #12  
TopBanana
Scooby Regular
 
TopBanana's Avatar
 
Join Date: Jan 2001
Posts: 9,781
Likes: 0
Received 0 Likes on 0 Posts
Post

Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
Sam Witwicky
Engine Management and ECU Remapping
17
13 November 2015 10:49 AM
Ganz1983
Subaru
5
02 October 2015 09:22 AM
sedge69
Wanted
0
01 October 2015 09:44 PM



Quick Reply: VB - Load an application to the System Tray



All times are GMT +1. The time now is 06:53 AM.