VB - Load an application to the System Tray
#1
Moderator
Thread Starter
Join Date: Dec 1998
Location: Staffs
Posts: 23,573
Likes: 0
Received 0 Likes
on
0 Posts
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.
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.
#2
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?
better still, why not put the code to send it to the systray in Form_Load itself?
#3
Moderator
Thread Starter
Join Date: Dec 1998
Location: Staffs
Posts: 23,573
Likes: 0
Received 0 Likes
on
0 Posts
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.
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.
#4
Scooby Regular
Join Date: Mar 2000
Location: Gloucestershire, home of the lawnmower.
Posts: 4,531
Likes: 0
Received 0 Likes
on
0 Posts
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
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
#5
Moderator
Thread Starter
Join Date: Dec 1998
Location: Staffs
Posts: 23,573
Likes: 0
Received 0 Likes
on
0 Posts
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.
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.
#7
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
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
Trending Topics
#8
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.
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.
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