Solved

Minimize to taskbar?

Posted on 1998-03-21
17
646 Views
Last Modified: 2011-04-14
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?
0
Comment
Question by:Sense
  • 4
  • 3
  • 3
  • +6
17 Comments
 
LVL 7

Expert Comment

by:kamall
ID: 1459561
Sense
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.
Regards
0
 

Author Comment

by:Sense
ID: 1459562
Kamall,

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.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1459563
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 www.mabry.com
0
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 6

Expert Comment

by:clifABB
ID: 1459564
In reference to your second question, As far as I know, there is no way to send an existing app to the tray.
0
 
LVL 7

Expert Comment

by:kamall
ID: 1459565
Sense,
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
0
 
LVL 7

Expert Comment

by:kamall
ID: 1459566
Sense,
If you have any difficulty, give me your email address and I will send you a working project.
Regards
0
 
LVL 39

Expert Comment

by:abel
ID: 1459567
Sense,
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 Shareware.com, 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.
0
 
LVL 1

Expert Comment

by:vsinha
ID: 1459568
"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)

0
 

Author Comment

by:Sense
ID: 1459569
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.
0
 

Expert Comment

by:Slasher
ID: 1459570
Sense,
             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)

Slasher@post1.com
0
 
LVL 39

Expert Comment

by:abel
ID: 1459571
Sense,

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
0
 

Expert Comment

by:mattyboy
ID: 1459572
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
0
 
LVL 39

Expert Comment

by:abel
ID: 1459573
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.
0
 

Author Comment

by:Sense
ID: 1459574
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 cb@funtv.com if you choose to send me something and I will give points to the person whose code works the best. Thanks.
0
 
LVL 1

Expert Comment

by:bitz
ID: 1459575
Sense, to use the system tray, look at this Knowledge Base artical about VB5 & the SysTray:

http://support.microsoft.com/support/kb/articles/q176/0/85.asp

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 (bitz@inside3d.com)
0
 
LVL 1

Accepted Solution

by:
juliocoelho earned 250 total points
ID: 1459576
Hi!

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 juliocoelho@hotmail.com for me to give give you the source code.

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

Author Comment

by:Sense
ID: 1459577
Thanks for everyone's help. I have learned a lot. Thanks for having patience with me as well.

Chris
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question