Solved

Minimize to taskbar?

Posted on 1998-03-21
17
637 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
"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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:Sense
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for everyone's help. I have learned a lot. Thanks for having patience with me as well.

Chris
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now