Important alert: (current site time 7/16/2013 3:15:05 AM EDT)
 

winzip icon

Put a form (or any window) in the TRAY! [Updated #4]

Email
Submitted on: 4/12/2001 10:59:07 PM
By: Jameson King  
Level: Advanced
User Rating: By 14 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 24843
(About the author)
 
      In my endeavor the make a weather program for my computer that would scroll weather information, I came to make this code. I was looking for a place to scroll the information without bothering any other programs and without the form taking focus. I was looking for the perfect place. I found it but it was of course occupied by something else. That something else was the task tray (Those small little icons and the clock in the bottom right hand corner of most windows computers). Well I said to myself how shall I take that area. I thought I would simply shape my form to that of the trays window. Then make my form a child of that window and set it's position to the topmost. Well my idea was correct and it works perfectly. You can use this technique for any window, it is far less involved then many other attempts witch require sub-classing. The window will resize to the RECT of the tray when the Task bar is resize and or moved and call the form to repaint also. I hope all of you can get something useful out of this I know have. *NEW* YOU can now resize the tray by doing a call ResizeTray (Number to resize by,A 1 or a 2 for rither making it larger or smaller) so call resizetray 11,1 would add eleven icons to the tray and call resizetray 11,2 would subtract eleven icons

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 18 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
4/12/2001 11:20:12 PMPure

I hope you guys/gals all love this code. If you have any questions comments don't be afraid to post them. If you use the program please vote for it, it always makes authors feel good :) and encourages them to release more stuff!
(If this comment was disrespectful, please report it.)

 
4/13/2001 2:29:23 AMEdwin Vermeer

You get 5 globes from me. I will definitely use this in one of my applications. Maybe you have an answer to a similar problem that I have. I have an application (in Dutch, see nice screenshots at http://www.beursmonitor.com) with does a lot with stock quotes (including a couple of tickertapes) Using your code for an other tickertape would be a nice extra. Currently I have a tickertape which is using a timer to reposition a form over the titlebar of any active application. This is disturbed a bit when the processor is 100% occupied. I already tried the SetParent function but this does not work (MSDN tells me: The new parent window and the child window must belong to the same application) Zo how come your's is working? One other thing: You can make the scrolling text look very nice by using a very easy to use textanimation control I wrote. Just have a look at http://www.planet-source-code.com/xq/ASP/txtCodeId.14615/lngWId.1/qx/vb/scripts/ShowCode .htm

(If this comment was disrespectful, please report it.)

 
4/13/2001 3:27:36 AMPure

Well that's because the MSDN information is wrong :). It works because my application is not it's own parent but a child of another window this allows the main application to be able to send the window the calls to change the text resize the lables ect. You'll run into a problem if you try to take a child form and set it's parent to 0 and try to make it it's own parent. It will work but it will effectivly sever the link between the actually running program and the graphical window. So nothing will update and your program will crash. Thanx for the scrolling text thing by the way :). Am I understanding you right that your positioning the form over the titbar area to display info? What Information are you displaying?


(If this comment was disrespectful, please report it.)

 
4/13/2001 3:29:13 AMJay

I have an Idea..

Have your form watch for the currently active window as it does now second have it check to see if the window state is not minimized if its not minimized then the person can see the title bar have the form then position itself over the titlebar. Now when the form is minimized or losses focus the form will either move to the next active window or hide while the form is minimized. This will help a little in cutting down on resources. On the other hand if it's just text you want displayed you could just change the caption of the currently active window to that of your text.. not sur eif this will do what you want but if you need help or if im just not egttig what your saying e-mail me at nemopsj@aol.com I'll try to help you out.
(If this comment was disrespectful, please report it.)

 
4/13/2001 8:10:12 AMMark Robert Strange

You gotta love this...5 globes all the way.
(If this comment was disrespectful, please report it.)

 
4/13/2001 10:40:15 AMEdwin Vermeer

Thanks for the info. I will defenitely try this. I am using it in combination with the textanimation control to display the current stock quotes in the titlebar of the active application. When I will get it to work as a child form I will strip it form my application and post it on PSC.
(If this comment was disrespectful, please report it.)

 
4/13/2001 11:10:54 AMoSiruS2685

All I gotta say is that this is sweet. Definitely a 5er.
(If this comment was disrespectful, please report it.)

 
4/17/2001 2:19:16 AMEdwin Vermeer

Hi, I tried the setparent but then even if i set the window to the topmost it wil be displayed behind the titlebar. So i don't thinkt that a parent child relationship will work in my case. The second thing that i tried was hooking into the paint function of the application by using the lpPrevWndProc = apiSetWindowLong(hwnd, GWL_WNDPROC, AddrOf(strFunctionName)) (This is the SetWindowLongA in user32) But this wil return an access denied error. So I am back to the beginning. Does somebody have an idea how i can paint into the titlebar of any application?
(If this comment was disrespectful, please report it.)

 
4/17/2001 2:06:58 PMPure

You know there is a way... You have to search for "Animated Title bar". This is what I found it animates the title bar with a picture but im sure with some tinkering/Canimbalising you can figure out how to get it to work.

"http://www.planetsourcecode.com/xq/ASP/txtCodeId.10295/lngWId.1/qx/vb/scri pts/ShowCode.htm"

p.s.
To all those who enjoy my systray program I'm adding a feature to expand the systray so it's large enough to hold whatever you want whilst also resizing the rest of the task bar so everything fits!


(If this comment was disrespectful, please report it.)

 
4/18/2001 2:52:32 AMEdwin Vermeer


Hi, As you can see the titlebar app is using the SetWindowLong and that will only work for the current application and i want to do this for all applications that are running.

That new feature sounds good!
(If this comment was disrespectful, please report it.)

 
4/18/2001 5:21:43 PMPure

Why does it need to be for all windows... that WILL eat up processing plus it's impracticle. I mean the currently active window will be the only one the user is looking at or at least the only one he will be paying attention too. So having it on all the others is pointless. Well at least in my mind.
(If this comment was disrespectful, please report it.)

 
4/22/2001 11:03:48 PMAnthony

This is nice, it would be cool if you could get the number of icons there before so that way you can have kinda a standard size like I would like mine to always be 6 icons big or something no matter how much they have
(If this comment was disrespectful, please report it.)

 
4/23/2001 4:04:38 PMPure

Good Idea, I'll add that
(If this comment was disrespectful, please report it.)

 
7/21/2002 6:50:34 AMIssamFe

i will add it to all my app, thx it's gr8
(If this comment was disrespectful, please report it.)

 
9/17/2004 3:07:58 PMEl_Maleador

Great code... can it be done without hiding the icons in tray? i mean, like and adition to the tray itself like the windows media player does
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.