Minimize to taskbar?

I would like to have my program minimize to the taskbar in the bottom right corner next to the time and sound control icon when running in the background.
1. How do I code this?
2. If i have an existing app, how would I send it there using the registry or editing config file of some sort?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You CAN NOT set the location of the minimized applications on the task bar. Windows have the absolute control of the locations of minimized applications and this can not be controlled form other programs. Minimized applications are are arranged from left to right and top to buttom on the task bar.
SenseAuthor Commented:

I think you may have misunderstood. If you look directly to the left of the time in the right corner of the taskbar, certain apps reside there minimized. ICQ, Vshield, Volume Control, dial-up networking, etc, all reside there while working in the background. It must be possible because 3rd party programs do it.

Thanks for the attempt, I would appreciate a follow up or answers from others.
Mabry has a control which allows you to minimize to the tray (the area you speak of).  There are ways of doing this strictly through code, but is difficult and you need call backs to respond to the clicks in the tray.
You can download a sample ocx from mabry at
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

In reference to your second question, As far as I know, there is no way to send an existing app to the tray.
Sorry for the misunderstanding. I thought that you want to get your application minimized on the right side of the task bar but not in the system tray. You didn't mention the system tray.

Here is the way to do it:

Declare Function GetMenu Lib "user32" Alias "GetMenuA" (ByVal hWnd As Long) As Long
Declare Function GetSubMenu Lib "user32" Alias "GetSubMenuA" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Declare Function GetMenuItemID Lib "user32" Alias "GetMenuItemIdA" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
Const BF_BITMAP = &H4

'See Microsoft Knowledge Base Article ID: Q71281
'Title: How to Implement a Bitmap Within a Visual Basic Menu

'hWnd - Window Handle
'PosIndex - position (zero-based) in the given menu of the pop-up menu
'ItemIndex - the item menu index(0, 1, 2, 3...)
'hBmp - 32-bit handle to the bitmap

Sub SetMenuBitmap(hWnd As Integer, PosIndex As Integer, ItemIndex As Integer, hBmp As Long)
Dim hMenu As Integer, hPopUp As Integer
Dim hItem As Integer, RC As Integer

hMenu = GetMenu(hWnd)
hPopUp = GetSubMenu(hMenu, PosIndex)
hItem = GetMenuItemID(hPopUp, ItemIndex)
RC = ModifyMenu(hMenu, hItem, BF_BITMAP, hItem, hBmp)

End Sub
If you have any difficulty, give me your email address and I will send you a working project.
For minimizing other windows then your own to the systray, you'll have to monitor the system for WM_SIZE messages with SIZE_MINIMIZE as the wparam. Do that with the MsgHoo32.ocx clifAbb speaks of. You can then hide the window and create an icon in the systray for it. Off course you'll have to process the way that that icon behaves (like the titlebar for example), it won't be done by the app itself. You may try to look for some app (I forgot the name) which does this trick. I think I found that on, but I'm not sure.

BTW, kamall,  SystemParametersInfo in conjunction with SPI_SETMINIMIZEDMETRICS and a type MINIMIZEDMETRICS would do the trick of starting bottom right going to top left for minimized windows, you can even set the size for it, but it looks rather unusual after I've gotten so accustomed to this way the windows are minimized.
"2. If i have an existing app, how would I send it there using the registry or editing config file of some sort?"

I have seen the ad. for a shareware program that can let you do it. You should be able to find it if you search for "system tray" at some shareware sites. (This was some time ago so I don't remember where exactly)

SenseAuthor Commented:
So abel,

You will have to forgive my ignorance about this subject, but when you say "monitor the system" what does that mean? I have found programs that can send shortcuts to the systray, but not programs that can RUN the program MINIMIZED to the systray. Those that have answered... which variety have you found? For example, I have found something called WinSettings97 which can only send shortcuts.

Abel please clarify how to HIDE the program in the systray without sending it to the taskbar... I could get by with doing that alone as I don't need to access it other than shutting it down. Thanks for all of your help and keep it coming.
             The Systray contains nothing but shortcuts to applications which are currently running in the system. The "owner" application of the each icon in the systray will recieve messages (something like mouse_down or mouse_move of a Form.). This owner application is HIDDEN .. not hidden IN the systray.. simply hidden  (form1.visible = false)

             I have written a module which i have modified from some examples i found on the net. I can email you a copy with a very simple working example.(vb 4.0 32bit format)

Unless you just want your own program in the systray (like Slasher points out) you can do this to "minimize" other applications to the systray (in steps):

- Set a systemwide hook
- Filter for WM_SIZE with wparam = SIZE_MINIMIZE
- When you get such a message do:
  - Check if it's a main window of an app
  - Change properties of window to HIDDEN
  - Place an icon identifying the window in the systray (or in a menu of your own app or so)
  - Check and react accordingly when somebody clicks on the systray-icon

That's about it.
You asked an explanation for what "monitoring the system" means. Well, in a nutshell:
In the windowing system most events are sent to the windows/apps and system via messages, like moving the mouse, clicking somewhere, creating a window, starting a DDE conversation and so on. You can set a HOOK to a window to track the messages send to that window and you can intercept them if you like. That's where the HOOK-api's are for. In C this is fairly easy, but doing this via the api's in VB is rather difficult. That's where the MsgHoo32.ocx comes in. You can let that ocx monitor a specific window for specific messages.

If you want me to help you further in this direction, that'll be ok, but keep in mind that the stuff isn't "easy" anymore. If what Slasher says is ok, just accept his answer.

Regards, Abel
Abel, how do you set a SYSTEMWIDE hook?

I am able to hook messages coming into the active Form in my App.  However, I am looking for a way to hook all system messages, specifically, the mouse coordinates.

Mattyboy, I can tell you, but this is not your question. If sense needs that info, he can ask for it (and maybe I give it, but as I stated, it isn't "easy"), but if you want that code, post a question and if I find it, I'll answer it for you.
SenseAuthor Commented:
Alright, sorry I took so long. I am more than happy to share my points for solving my little problem. So just to re-clarify... I would like to force a compiled program to hide in the systray and not show up on the taskbar. Also, I would like the code to do this for my own programs except these I would like to send to the taskbar. Ok, thanks for all that have responded thus far. My email is if you choose to send me something and I will give points to the person whose code works the best. Thanks.
Sense, to use the system tray, look at this Knowledge Base artical about VB5 & the SysTray:

I read it and it seems to be complete.  About it being sent to the tray automatically, all you have to do is in your settings file, save that setting.  If it is true, call the function to put in the task tray that is noted on the KB Artical.  Hope this helps.

-bitz (

I already have an application that does that with subclassing (the subclassing component is made with 100% VB code).
but it's a lot of code (the component side) and I also can't publish here, so drop me a line at for me to give give you the source code.

I hope that what I have gives you what you need.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SenseAuthor Commented:
Thanks for everyone's help. I have learned a lot. Thanks for having patience with me as well.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.